Avoid failing when a dependency is too old
authorDebian Science Maintainers <debian-science-maintainers@lists.alioth.debian.org>
Tue, 9 Dec 2025 11:19:37 +0000 (11:19 +0000)
committerGraham Inggs <ginggs@debian.org>
Tue, 9 Dec 2025 11:19:37 +0000 (11:19 +0000)
(some of them are pulled in by other dependencies, so
just not including them in d/control doesn't stop them being installed)

Most of the content of this patch was generated by the following Python code:

import pathlib
import re

basedir = pathlib.Path.cwd()
if not (basedir / 'pandas/tests').exists():
    raise FileNotFoundError('must be run from the pandas root')
for source_file in basedir.glob('pandas/**/*.py'):
    with open(source_file, 'r') as fd:
        source_text = fd.read()
    if 'pytest.importorskip' in source_text:
        source_text = re.sub(r'pytest\.importorskip(.*)minversion', r'td.versioned_importorskip\1min_version', source_text)
        source_text = re.sub(r'pytest\.importorskip', r'td.versioned_importorskip', source_text)
        if '_test_decorators as td' not in source_text:
            # add the import if it isn't already present
            source_text, count = re.subn(r'^(import pandas|from pandas.*import)',r'import pandas.util._test_decorators as td\n\1', source_text, count=1, flags=re.MULTILINE)
            if count != 1:
                raise KeyError("failed to add import")
        with open(source_file, 'w') as fd:
            fd.write(source_text)

Author: Rebecca N. Palmer <rebecca_palmer@zoho.com>
Forwarded: no

Gbp-Pq: Name versioned_importorskip.patch

152 files changed:
pandas/_testing/_io.py
pandas/conftest.py
pandas/tests/apply/test_frame_apply.py
pandas/tests/apply/test_numba.py
pandas/tests/arrays/categorical/test_warnings.py
pandas/tests/arrays/datetimes/test_constructors.py
pandas/tests/arrays/interval/test_interval_pyarrow.py
pandas/tests/arrays/masked/test_arrow_compat.py
pandas/tests/arrays/period/test_arrow_compat.py
pandas/tests/arrays/sparse/test_accessor.py
pandas/tests/arrays/sparse/test_constructors.py
pandas/tests/arrays/string_/test_string.py
pandas/tests/arrays/string_/test_string_arrow.py
pandas/tests/computation/test_compat.py
pandas/tests/copy_view/test_astype.py
pandas/tests/dtypes/test_common.py
pandas/tests/dtypes/test_inference.py
pandas/tests/extension/test_arrow.py
pandas/tests/extension/test_string.py
pandas/tests/frame/indexing/test_setitem.py
pandas/tests/frame/methods/test_astype.py
pandas/tests/frame/methods/test_convert_dtypes.py
pandas/tests/frame/methods/test_cov_corr.py
pandas/tests/frame/methods/test_describe.py
pandas/tests/frame/methods/test_dot.py
pandas/tests/frame/methods/test_info.py
pandas/tests/frame/methods/test_interpolate.py
pandas/tests/frame/methods/test_join.py
pandas/tests/frame/methods/test_rank.py
pandas/tests/frame/test_api.py
pandas/tests/frame/test_arrow_interface.py
pandas/tests/frame/test_constructors.py
pandas/tests/frame/test_query_eval.py
pandas/tests/frame/test_reductions.py
pandas/tests/frame/test_repr.py
pandas/tests/frame/test_subclass.py
pandas/tests/frame/test_ufunc.py
pandas/tests/generic/test_finalize.py
pandas/tests/generic/test_to_xarray.py
pandas/tests/groupby/aggregate/test_numba.py
pandas/tests/groupby/test_counting.py
pandas/tests/groupby/test_groupby.py
pandas/tests/groupby/test_numba.py
pandas/tests/groupby/test_numeric_only.py
pandas/tests/groupby/test_timegrouper.py
pandas/tests/groupby/transform/test_numba.py
pandas/tests/indexes/multi/test_constructors.py
pandas/tests/indexes/numeric/test_indexing.py
pandas/tests/indexes/test_base.py
pandas/tests/indexing/test_datetime.py
pandas/tests/indexing/test_loc.py
pandas/tests/interchange/test_impl.py
pandas/tests/interchange/test_utils.py
pandas/tests/io/conftest.py
pandas/tests/io/excel/test_odf.py
pandas/tests/io/excel/test_odswriter.py
pandas/tests/io/excel/test_openpyxl.py
pandas/tests/io/excel/test_style.py
pandas/tests/io/excel/test_xlrd.py
pandas/tests/io/excel/test_xlsxwriter.py
pandas/tests/io/formats/style/test_bar.py
pandas/tests/io/formats/style/test_exceptions.py
pandas/tests/io/formats/style/test_format.py
pandas/tests/io/formats/style/test_highlight.py
pandas/tests/io/formats/style/test_html.py
pandas/tests/io/formats/style/test_matplotlib.py
pandas/tests/io/formats/style/test_non_unique.py
pandas/tests/io/formats/style/test_style.py
pandas/tests/io/formats/style/test_to_latex.py
pandas/tests/io/formats/style/test_to_string.py
pandas/tests/io/formats/style/test_tooltip.py
pandas/tests/io/formats/test_format.py
pandas/tests/io/formats/test_to_excel.py
pandas/tests/io/formats/test_to_latex.py
pandas/tests/io/formats/test_to_markdown.py
pandas/tests/io/formats/test_to_string.py
pandas/tests/io/json/test_pandas.py
pandas/tests/io/json/test_readlines.py
pandas/tests/io/parser/conftest.py
pandas/tests/io/parser/dtypes/test_dtypes_basic.py
pandas/tests/io/parser/test_concatenate_chunks.py
pandas/tests/io/parser/test_multi_thread.py
pandas/tests/io/parser/test_network.py
pandas/tests/io/parser/test_python_parser_only.py
pandas/tests/io/parser/test_read_fwf.py
pandas/tests/io/parser/test_upcast.py
pandas/tests/io/pytables/common.py
pandas/tests/io/pytables/test_append.py
pandas/tests/io/pytables/test_compat.py
pandas/tests/io/pytables/test_round_trip.py
pandas/tests/io/pytables/test_store.py
pandas/tests/io/pytables/test_subclass.py
pandas/tests/io/test_clipboard.py
pandas/tests/io/test_common.py
pandas/tests/io/test_feather.py
pandas/tests/io/test_fsspec.py
pandas/tests/io/test_gcs.py
pandas/tests/io/test_html.py
pandas/tests/io/test_http_headers.py
pandas/tests/io/test_orc.py
pandas/tests/io/test_parquet.py
pandas/tests/io/test_pickle.py
pandas/tests/io/test_s3.py
pandas/tests/io/test_spss.py
pandas/tests/io/test_sql.py
pandas/tests/io/test_stata.py
pandas/tests/io/xml/test_to_xml.py
pandas/tests/io/xml/test_xml.py
pandas/tests/plotting/conftest.py
pandas/tests/plotting/frame/test_frame.py
pandas/tests/plotting/frame/test_frame_color.py
pandas/tests/plotting/frame/test_frame_groupby.py
pandas/tests/plotting/frame/test_frame_legend.py
pandas/tests/plotting/frame/test_frame_subplots.py
pandas/tests/plotting/frame/test_hist_box_by.py
pandas/tests/plotting/test_boxplot_method.py
pandas/tests/plotting/test_common.py
pandas/tests/plotting/test_converter.py
pandas/tests/plotting/test_datetimelike.py
pandas/tests/plotting/test_groupby.py
pandas/tests/plotting/test_hist_method.py
pandas/tests/plotting/test_misc.py
pandas/tests/plotting/test_series.py
pandas/tests/plotting/test_style.py
pandas/tests/reductions/test_stat_reductions.py
pandas/tests/resample/test_datetime_index.py
pandas/tests/reshape/merge/test_merge.py
pandas/tests/series/accessors/test_list_accessor.py
pandas/tests/series/accessors/test_struct_accessor.py
pandas/tests/series/methods/test_convert_dtypes.py
pandas/tests/series/methods/test_cov_corr.py
pandas/tests/series/methods/test_drop_duplicates.py
pandas/tests/series/methods/test_explode.py
pandas/tests/series/methods/test_interpolate.py
pandas/tests/series/methods/test_rank.py
pandas/tests/series/methods/test_reset_index.py
pandas/tests/series/test_formats.py
pandas/tests/series/test_logical_ops.py
pandas/tests/series/test_reductions.py
pandas/tests/strings/test_extract.py
pandas/tests/test_algos.py
pandas/tests/test_downstream.py
pandas/tests/test_nanops.py
pandas/tests/test_optional_dependency.py
pandas/tests/tools/test_to_datetime.py
pandas/tests/tools/test_to_numeric.py
pandas/tests/tools/test_to_timedelta.py
pandas/tests/window/test_numba.py
pandas/tests/window/test_online.py
pandas/tests/window/test_rolling_skew_kurt.py
pandas/tests/window/test_win_type.py
pandas/util/_test_decorators.py

index 95977edb600ade42a8f8a1fada2b5085cee1da56..df97baec453aa28cd013a2feeef5f062e8c40548 100644 (file)
@@ -109,7 +109,8 @@ def round_trip_localpath(writer, reader, path: str | None = None):
     """
     import pytest
 
-    LocalPath = pytest.importorskip("py.path").local
+    import pandas.util._test_decorators as td
+    LocalPath = td.versioned_importorskip("py.path").local
     if path is None:
         path = "___localpath___"
     with ensure_clean(path) as path:
index f3971ea087a8f4ff325794c92baee0ec107ed20c..46263a7695141d9a532cc671068ac0c6d789cc9a 100644 (file)
@@ -1901,7 +1901,7 @@ def ip():
 
     Will raise a skip if IPython is not installed.
     """
-    pytest.importorskip("IPython", minversion="6.0.0")
+    td.versioned_importorskip("IPython", min_version="6.0.0")
     from IPython.core.interactiveshell import InteractiveShell
 
     # GH#35711 make sure sqlite history file handle is not leaked
@@ -1918,7 +1918,7 @@ def spmatrix(request):
     """
     Yields scipy sparse matrix classes.
     """
-    sparse = pytest.importorskip("scipy.sparse")
+    sparse = td.versioned_importorskip("scipy.sparse")
 
     return getattr(sparse, request.param + "_matrix")
 
index 1a776892b7bb754e16aaa34e6dbe281b354ee751..be2ac3d4d98f964e8842cc2162073c376df65d96 100644 (file)
@@ -4,6 +4,7 @@ import warnings
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas.compat import is_platform_arm
 
 from pandas.core.dtypes.dtypes import CategoricalDtype
@@ -38,7 +39,7 @@ def int_frame_const_col():
 @pytest.fixture(params=["python", pytest.param("numba", marks=pytest.mark.single_cpu)])
 def engine(request):
     if request.param == "numba":
-        pytest.importorskip("numba")
+        td.versioned_importorskip("numba")
     return request.param
 
 
@@ -68,7 +69,7 @@ def test_apply(float_frame, engine, request):
 @pytest.mark.parametrize("raw", [True, False])
 def test_apply_args(float_frame, axis, raw, engine, request):
     if engine == "numba":
-        numba = pytest.importorskip("numba")
+        numba = td.versioned_importorskip("numba")
         if Version(numba.__version__) == Version("0.61") and is_platform_arm():
             pytest.skip(f"Segfaults on ARM platforms with numba {numba.__version__}")
         mark = pytest.mark.xfail(reason="numba engine doesn't support args")
index c211073f758881fdd9e2acf72b30e86b9aa49cb2..06858415dc4ba8748a7670520e351217b06a5899 100644 (file)
@@ -14,7 +14,7 @@ from pandas.util.version import Version
 
 pytestmark = [td.skip_if_no("numba"), pytest.mark.single_cpu, pytest.mark.skipif()]
 
-numba = pytest.importorskip("numba")
+numba = td.versioned_importorskip("numba")
 pytestmark.append(
     pytest.mark.skipif(
         Version(numba.__version__) == Version("0.61") and is_platform_arm(),
@@ -110,7 +110,7 @@ def test_numba_nonunique_unsupported(apply_axis):
 
 
 def test_numba_unsupported_dtypes(apply_axis):
-    pytest.importorskip("pyarrow")
+    td.versioned_importorskip("pyarrow")
     f = lambda x: x
     df = DataFrame({"a": [1, 2], "b": ["a", "b"], "c": [4, 5]})
     df["c"] = df["c"].astype("double[pyarrow]")
index 68c59706a6c3bf93908108c337b51c8da187cbb4..2cfef3fc40e0cc239f1754a9829122b8ea279c34 100644 (file)
@@ -1,12 +1,13 @@
 import pytest
 
+import pandas.util._test_decorators as td
 import pandas._testing as tm
 
 
 class TestCategoricalWarnings:
     def test_tab_complete_warning(self, ip):
         # https://github.com/pandas-dev/pandas/issues/16409
-        pytest.importorskip("IPython", minversion="6.0.0")
+        td.versioned_importorskip("IPython", min_version="6.0.0")
         from IPython.core.completer import provisionalcompleter
 
         code = "import pandas as pd; c = pd.Categorical([])"
index 3652b5fec46bbe7a519dd2c3a196ac87bd74784f..1431dc25bfcc1ed6bd8c7518d303ea6a077ca677 100644 (file)
@@ -1,6 +1,7 @@
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas._libs import iNaT
 
 from pandas.core.dtypes.dtypes import DatetimeTZDtype
@@ -226,7 +227,7 @@ COARSE_TO_FINE_SAFE = [123, None, -123]
 def test_from_arrow_with_different_units_and_timezones_with(
     pa_unit, pd_unit, pa_tz, pd_tz, data
 ):
-    pa = pytest.importorskip("pyarrow")
+    pa = td.versioned_importorskip("pyarrow")
 
     pa_type = pa.timestamp(pa_unit, tz=pa_tz)
     arr = pa.array(data, type=pa_type)
@@ -253,7 +254,7 @@ def test_from_arrow_with_different_units_and_timezones_with(
     ],
 )
 def test_from_arrow_from_empty(unit, tz):
-    pa = pytest.importorskip("pyarrow")
+    pa = td.versioned_importorskip("pyarrow")
 
     data = []
     arr = pa.array(data)
@@ -269,7 +270,7 @@ def test_from_arrow_from_empty(unit, tz):
 
 
 def test_from_arrow_from_integers():
-    pa = pytest.importorskip("pyarrow")
+    pa = td.versioned_importorskip("pyarrow")
 
     data = [0, 123456789, None, 2**63 - 1, iNaT, -123456789]
     arr = pa.array(data)
index ef8701be81e2b9248c29fc4e901161fd18d72bbe..455b026227f60a80f1e3712f660b429720bbe23f 100644 (file)
@@ -1,13 +1,14 @@
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 import pandas as pd
 import pandas._testing as tm
 from pandas.core.arrays import IntervalArray
 
 
 def test_arrow_extension_type():
-    pa = pytest.importorskip("pyarrow")
+    pa = td.versioned_importorskip("pyarrow")
 
     from pandas.core.arrays.arrow.extension_types import ArrowIntervalType
 
@@ -23,7 +24,7 @@ def test_arrow_extension_type():
 
 
 def test_arrow_array():
-    pa = pytest.importorskip("pyarrow")
+    pa = td.versioned_importorskip("pyarrow")
 
     from pandas.core.arrays.arrow.extension_types import ArrowIntervalType
 
@@ -52,7 +53,7 @@ def test_arrow_array():
 
 
 def test_arrow_array_missing():
-    pa = pytest.importorskip("pyarrow")
+    pa = td.versioned_importorskip("pyarrow")
 
     from pandas.core.arrays.arrow.extension_types import ArrowIntervalType
 
@@ -89,7 +90,7 @@ def test_arrow_array_missing():
     ids=["float", "datetime64[ns]"],
 )
 def test_arrow_table_roundtrip(breaks):
-    pa = pytest.importorskip("pyarrow")
+    pa = td.versioned_importorskip("pyarrow")
 
     from pandas.core.arrays.arrow.extension_types import ArrowIntervalType
 
@@ -125,7 +126,7 @@ def test_arrow_table_roundtrip(breaks):
     ids=["float", "datetime64[ns]"],
 )
 def test_arrow_table_roundtrip_without_metadata(breaks):
-    pa = pytest.importorskip("pyarrow")
+    pa = td.versioned_importorskip("pyarrow")
 
     arr = IntervalArray.from_breaks(breaks)
     arr[1] = None
@@ -145,7 +146,7 @@ def test_from_arrow_from_raw_struct_array():
     # in case pyarrow lost the Interval extension type (eg on parquet roundtrip
     # with datetime64[ns] subtype, see GH-45881), still allow conversion
     # from arrow to IntervalArray
-    pa = pytest.importorskip("pyarrow")
+    pa = td.versioned_importorskip("pyarrow")
 
     arr = pa.array([{"left": 0, "right": 1}, {"left": 1, "right": 2}])
     dtype = pd.IntervalDtype(np.dtype("int64"), closed="neither")
index 293ee4095d02e1b35ace33458e38c61d87181373..47778aea293f22f58468b53736c92c8504a6b067 100644 (file)
@@ -1,6 +1,7 @@
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 import pandas as pd
 import pandas._testing as tm
 
@@ -9,7 +10,7 @@ pytestmark = pytest.mark.filterwarnings(
 )
 
 
-pa = pytest.importorskip("pyarrow")
+pa = td.versioned_importorskip("pyarrow")
 
 from pandas.core.arrays.arrow._arrow_utils import pyarrow_array_to_numpy_and_mask
 
index 431309aca0df21dbe885ae015b10c3c21f0134a2..11e5d3430ec466f04371796985186a0e57f33756 100644 (file)
@@ -1,5 +1,6 @@
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas.compat.pyarrow import pa_version_under10p1
 
 from pandas.core.dtypes.dtypes import PeriodDtype
@@ -16,7 +17,7 @@ pytestmark = pytest.mark.filterwarnings(
 )
 
 
-pa = pytest.importorskip("pyarrow")
+pa = td.versioned_importorskip("pyarrow")
 
 
 def test_arrow_extension_type():
index 87eb7bcfa9cee3e92386ad0f148b896c0e682b07..8f9034af9b46166b79cf9d128fc2050ceeb02ccc 100644 (file)
@@ -3,6 +3,7 @@ import string
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 import pandas as pd
 from pandas import SparseDtype
 import pandas._testing as tm
@@ -26,7 +27,7 @@ class TestSeriesAccessor:
         assert result == expected
 
     def test_from_coo(self):
-        scipy_sparse = pytest.importorskip("scipy.sparse")
+        scipy_sparse = td.versioned_importorskip("scipy.sparse")
 
         row = [0, 3, 1, 0]
         col = [0, 3, 1, 2]
@@ -64,7 +65,7 @@ class TestSeriesAccessor:
     def test_to_coo(
         self, sort_labels, expected_rows, expected_cols, expected_values_pos
     ):
-        sp_sparse = pytest.importorskip("scipy.sparse")
+        sp_sparse = td.versioned_importorskip("scipy.sparse")
 
         values = SparseArray([0, np.nan, 1, 0, None, 3], fill_value=0)
         index = pd.MultiIndex.from_tuples(
@@ -107,7 +108,7 @@ class TestFrameAccessor:
     @pytest.mark.parametrize("labels", [None, list(string.ascii_letters[:10])])
     @pytest.mark.parametrize("dtype", ["float64", "int64"])
     def test_from_spmatrix(self, format, labels, dtype):
-        sp_sparse = pytest.importorskip("scipy.sparse")
+        sp_sparse = td.versioned_importorskip("scipy.sparse")
 
         sp_dtype = SparseDtype(dtype, np.array(0, dtype=dtype).item())
 
@@ -120,7 +121,7 @@ class TestFrameAccessor:
 
     @pytest.mark.parametrize("format", ["csc", "csr", "coo"])
     def test_from_spmatrix_including_explicit_zero(self, format):
-        sp_sparse = pytest.importorskip("scipy.sparse")
+        sp_sparse = td.versioned_importorskip("scipy.sparse")
 
         mat = sp_sparse.random(10, 2, density=0.5, format=format)
         mat.data[0] = 0
@@ -134,7 +135,7 @@ class TestFrameAccessor:
         [["a", "b"], pd.MultiIndex.from_product([["A"], ["a", "b"]]), ["a", "a"]],
     )
     def test_from_spmatrix_columns(self, columns):
-        sp_sparse = pytest.importorskip("scipy.sparse")
+        sp_sparse = td.versioned_importorskip("scipy.sparse")
 
         dtype = SparseDtype("float64", 0.0)
 
@@ -147,7 +148,7 @@ class TestFrameAccessor:
         "colnames", [("A", "B"), (1, 2), (1, pd.NA), (0.1, 0.2), ("x", "x"), (0, 0)]
     )
     def test_to_coo(self, colnames):
-        sp_sparse = pytest.importorskip("scipy.sparse")
+        sp_sparse = td.versioned_importorskip("scipy.sparse")
 
         df = pd.DataFrame(
             {colnames[0]: [0, 1, 0], colnames[1]: [1, 0, 0]}, dtype="Sparse[int64, 0]"
@@ -158,7 +159,7 @@ class TestFrameAccessor:
 
     @pytest.mark.parametrize("fill_value", [1, np.nan])
     def test_to_coo_nonzero_fill_val_raises(self, fill_value):
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         df = pd.DataFrame(
             {
                 "A": SparseArray(
@@ -174,7 +175,7 @@ class TestFrameAccessor:
 
     def test_to_coo_midx_categorical(self):
         # GH#50996
-        sp_sparse = pytest.importorskip("scipy.sparse")
+        sp_sparse = td.versioned_importorskip("scipy.sparse")
 
         midx = pd.MultiIndex.from_arrays(
             [
@@ -219,7 +220,7 @@ class TestFrameAccessor:
     @pytest.mark.parametrize("dtype", ["int64", "float64"])
     @pytest.mark.parametrize("dense_index", [True, False])
     def test_series_from_coo(self, dtype, dense_index):
-        sp_sparse = pytest.importorskip("scipy.sparse")
+        sp_sparse = td.versioned_importorskip("scipy.sparse")
 
         A = sp_sparse.eye(3, format="coo", dtype=dtype)
         result = pd.Series.sparse.from_coo(A, dense_index=dense_index)
@@ -239,7 +240,7 @@ class TestFrameAccessor:
 
     def test_series_from_coo_incorrect_format_raises(self):
         # gh-26554
-        sp_sparse = pytest.importorskip("scipy.sparse")
+        sp_sparse = td.versioned_importorskip("scipy.sparse")
 
         m = sp_sparse.csr_matrix(np.array([[0, 1], [0, 0]]))
         with pytest.raises(
index 2831c8abdaf137b6454ea8f73bff7e94a3ec1b2b..e66a041e58fe1b6849fdc9f8518f7147ec6c7c42 100644 (file)
@@ -1,6 +1,7 @@
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas._libs.sparse import IntIndex
 
 import pandas as pd
@@ -188,7 +189,7 @@ class TestConstructors:
     @pytest.mark.parametrize("format", ["coo", "csc", "csr"])
     @pytest.mark.parametrize("size", [0, 10])
     def test_from_spmatrix(self, size, format):
-        sp_sparse = pytest.importorskip("scipy.sparse")
+        sp_sparse = td.versioned_importorskip("scipy.sparse")
 
         mat = sp_sparse.random(size, 1, density=0.5, format=format)
         result = SparseArray.from_spmatrix(mat)
@@ -199,7 +200,7 @@ class TestConstructors:
 
     @pytest.mark.parametrize("format", ["coo", "csc", "csr"])
     def test_from_spmatrix_including_explicit_zero(self, format):
-        sp_sparse = pytest.importorskip("scipy.sparse")
+        sp_sparse = td.versioned_importorskip("scipy.sparse")
 
         mat = sp_sparse.random(10, 1, density=0.5, format=format)
         mat.data[0] = 0
@@ -210,7 +211,7 @@ class TestConstructors:
         tm.assert_numpy_array_equal(result, expected)
 
     def test_from_spmatrix_raises(self):
-        sp_sparse = pytest.importorskip("scipy.sparse")
+        sp_sparse = td.versioned_importorskip("scipy.sparse")
 
         mat = sp_sparse.eye(5, 4, format="csc")
 
index b468480cf5f865461c196756c979c8dfd9fa4b2b..14af9f16d0cd46d0718eb14615ef60859aa81423 100644 (file)
@@ -66,7 +66,7 @@ def string_dtype_highest_priority(dtype1, dtype2):
 
 
 def test_dtype_constructor():
-    pytest.importorskip("pyarrow")
+    td.versioned_importorskip("pyarrow")
 
     with tm.assert_produces_warning(FutureWarning):
         dtype = pd.StringDtype("pyarrow_numpy")
@@ -74,7 +74,7 @@ def test_dtype_constructor():
 
 
 def test_dtype_equality():
-    pytest.importorskip("pyarrow")
+    td.versioned_importorskip("pyarrow")
 
     dtype1 = pd.StringDtype("python")
     dtype2 = pd.StringDtype("pyarrow")
@@ -596,7 +596,7 @@ def test_fillna_args(dtype):
 
 def test_arrow_array(dtype):
     # protocol added in 0.15.0
-    pa = pytest.importorskip("pyarrow")
+    pa = td.versioned_importorskip("pyarrow")
     import pyarrow.compute as pc
 
     data = pd.array(["a", "b", "c"], dtype=dtype)
@@ -612,7 +612,7 @@ def test_arrow_array(dtype):
 @pytest.mark.filterwarnings("ignore:Passing a BlockManager:DeprecationWarning")
 def test_arrow_roundtrip(dtype, string_storage, using_infer_string):
     # roundtrip possible from arrow 1.0.0
-    pa = pytest.importorskip("pyarrow")
+    pa = td.versioned_importorskip("pyarrow")
 
     data = pd.array(["a", "b", None], dtype=dtype)
     df = pd.DataFrame({"a": data})
@@ -640,7 +640,7 @@ def test_arrow_roundtrip(dtype, string_storage, using_infer_string):
 @pytest.mark.filterwarnings("ignore:Passing a BlockManager:DeprecationWarning")
 def test_arrow_from_string(using_infer_string):
     # not roundtrip,  but starting with pyarrow table without pandas metadata
-    pa = pytest.importorskip("pyarrow")
+    pa = td.versioned_importorskip("pyarrow")
     table = pa.table({"a": pa.array(["a", "b", None], type=pa.string())})
 
     result = table.to_pandas()
@@ -655,7 +655,7 @@ def test_arrow_from_string(using_infer_string):
 @pytest.mark.filterwarnings("ignore:Passing a BlockManager:DeprecationWarning")
 def test_arrow_load_from_zero_chunks(dtype, string_storage, using_infer_string):
     # GH-41040
-    pa = pytest.importorskip("pyarrow")
+    pa = td.versioned_importorskip("pyarrow")
 
     data = pd.array([], dtype=dtype)
     df = pd.DataFrame({"a": data})
@@ -821,7 +821,7 @@ def test_isin_string_array(dtype, dtype2):
 
 
 def test_isin_arrow_string_array(dtype):
-    pa = pytest.importorskip("pyarrow")
+    pa = td.versioned_importorskip("pyarrow")
     s = pd.Series(["a", "b", None], dtype=dtype)
 
     result = s.isin(pd.array(["a", "c"], dtype=pd.ArrowDtype(pa.string())))
index aa87f5fc0f49a07b40174ef7aad5b12349d28a5b..d50ec16def25a7fa3e7ed7648e6e05a09007d6b9 100644 (file)
@@ -19,7 +19,7 @@ from pandas.core.arrays.string_arrow import (
 
 
 def test_eq_all_na():
-    pytest.importorskip("pyarrow")
+    td.versioned_importorskip("pyarrow")
     a = pd.array([pd.NA, pd.NA], dtype=StringDtype("pyarrow"))
     result = a == a
     expected = pd.array([pd.NA, pd.NA], dtype="boolean[pyarrow]")
@@ -51,7 +51,7 @@ def test_config_bad_storage_raises():
 @pytest.mark.parametrize("chunked", [True, False])
 @pytest.mark.parametrize("array_lib", ["numpy", "pyarrow"])
 def test_constructor_not_string_type_raises(array_lib, chunked):
-    pa = pytest.importorskip("pyarrow")
+    pa = td.versioned_importorskip("pyarrow")
 
     array_lib = pa if array_lib == "pyarrow" else np
 
@@ -72,7 +72,7 @@ def test_constructor_not_string_type_raises(array_lib, chunked):
 
 @pytest.mark.parametrize("chunked", [True, False])
 def test_constructor_not_string_type_value_dictionary_raises(chunked):
-    pa = pytest.importorskip("pyarrow")
+    pa = td.versioned_importorskip("pyarrow")
 
     arr = pa.array([1, 2, 3], pa.dictionary(pa.int32(), pa.int32()))
     if chunked:
@@ -88,7 +88,7 @@ def test_constructor_not_string_type_value_dictionary_raises(chunked):
 @pytest.mark.parametrize("string_type", ["string", "large_string"])
 @pytest.mark.parametrize("chunked", [True, False])
 def test_constructor_valid_string_type_value_dictionary(string_type, chunked):
-    pa = pytest.importorskip("pyarrow")
+    pa = td.versioned_importorskip("pyarrow")
 
     arr = pa.array(["1", "2", "3"], getattr(pa, string_type)()).dictionary_encode()
     if chunked:
@@ -102,7 +102,7 @@ def test_constructor_valid_string_type_value_dictionary(string_type, chunked):
 @pytest.mark.parametrize("chunked", [True, False])
 def test_constructor_valid_string_view(chunked):
     # requires pyarrow>=18 for casting string_view to string
-    pa = pytest.importorskip("pyarrow", minversion="18")
+    pa = td.versioned_importorskip("pyarrow", min_version="18")
 
     arr = pa.array(["1", "2", "3"], pa.string_view())
     if chunked:
@@ -115,14 +115,14 @@ def test_constructor_valid_string_view(chunked):
 
 def test_constructor_from_list():
     # GH#27673
-    pytest.importorskip("pyarrow")
+    td.versioned_importorskip("pyarrow")
     result = pd.Series(["E"], dtype=StringDtype(storage="pyarrow"))
     assert isinstance(result.dtype, StringDtype)
     assert result.dtype.storage == "pyarrow"
 
 
 def test_from_sequence_wrong_dtype_raises(using_infer_string):
-    pytest.importorskip("pyarrow")
+    td.versioned_importorskip("pyarrow")
     with pd.option_context("string_storage", "python"):
         ArrowStringArray._from_sequence(["a", None, "c"], dtype="string")
 
@@ -215,7 +215,7 @@ def test_pyarrow_not_installed_raises():
     ],
 )
 def test_setitem(multiple_chunks, key, value, expected):
-    pa = pytest.importorskip("pyarrow")
+    pa = td.versioned_importorskip("pyarrow")
 
     result = pa.array(list("abcde"))
     expected = pa.array(expected)
@@ -232,7 +232,7 @@ def test_setitem(multiple_chunks, key, value, expected):
 
 
 def test_setitem_invalid_indexer_raises():
-    pa = pytest.importorskip("pyarrow")
+    pa = td.versioned_importorskip("pyarrow")
 
     arr = ArrowStringArray(pa.array(list("abcde")))
 
@@ -258,7 +258,7 @@ def test_setitem_invalid_indexer_raises():
 @pytest.mark.parametrize("na_value", [pd.NA, np.nan])
 def test_pickle_roundtrip(na_value):
     # GH 42600
-    pytest.importorskip("pyarrow")
+    td.versioned_importorskip("pyarrow")
     dtype = StringDtype("pyarrow", na_value=na_value)
     expected = pd.Series(range(10), dtype=dtype)
     expected_sliced = expected.head(2)
@@ -276,7 +276,7 @@ def test_pickle_roundtrip(na_value):
 
 def test_string_dtype_error_message():
     # GH#55051
-    pytest.importorskip("pyarrow")
+    td.versioned_importorskip("pyarrow")
     msg = "Storage must be 'python' or 'pyarrow'."
     with pytest.raises(ValueError, match=msg):
         StringDtype("bla")
index 856a5b3a22a95d35cc577050f52d762b065e3ddf..c63cd8c9b7e5271a40c4d291d3d1ff41c8213e2d 100644 (file)
@@ -1,5 +1,6 @@
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas.compat._optional import VERSIONS
 
 import pandas as pd
@@ -13,7 +14,7 @@ def test_compat():
 
     from pandas.core.computation.check import NUMEXPR_INSTALLED
 
-    ne = pytest.importorskip("numexpr")
+    ne = td.versioned_importorskip("numexpr")
 
     ver = ne.__version__
     if Version(ver) < Version(VERSIONS["numexpr"]):
@@ -26,7 +27,7 @@ def test_compat():
 @pytest.mark.parametrize("parser", expr.PARSERS)
 def test_invalid_numexpr_version(engine, parser):
     if engine == "numexpr":
-        pytest.importorskip("numexpr")
+        td.versioned_importorskip("numexpr")
     a, b = 1, 2  # noqa: F841
     res = pd.eval("a + b", engine=engine, parser=parser)
     assert res == 3
index 45fc3333c49a7722db200985d8232b9470baa205..16e69702b984f6f8b507daf2fec35bb4a7d4184b 100644 (file)
@@ -46,7 +46,7 @@ def test_astype_single_dtype(using_copy_on_write):
 @pytest.mark.parametrize("new_dtype", ["int64", "Int64", "int64[pyarrow]"])
 def test_astype_avoids_copy(using_copy_on_write, dtype, new_dtype):
     if new_dtype == "int64[pyarrow]":
-        pytest.importorskip("pyarrow")
+        td.versioned_importorskip("pyarrow")
     df = DataFrame({"a": [1, 2, 3]}, dtype=dtype)
     df_orig = df.copy()
     df2 = df.astype(new_dtype)
@@ -71,7 +71,7 @@ def test_astype_avoids_copy(using_copy_on_write, dtype, new_dtype):
 @pytest.mark.parametrize("dtype", ["float64", "int32", "Int32", "int32[pyarrow]"])
 def test_astype_different_target_dtype(using_copy_on_write, dtype):
     if dtype == "int32[pyarrow]":
-        pytest.importorskip("pyarrow")
+        td.versioned_importorskip("pyarrow")
     df = DataFrame({"a": [1, 2, 3]})
     df_orig = df.copy()
     df2 = df.astype(dtype)
@@ -219,7 +219,7 @@ def test_astype_different_timezones_different_reso(using_copy_on_write):
 
 
 def test_astype_arrow_timestamp(using_copy_on_write):
-    pytest.importorskip("pyarrow")
+    td.versioned_importorskip("pyarrow")
     df = DataFrame(
         {
             "a": [
index 579f5636922dc3fb4ed652e1fa374607ec57501a..0478cc28ec34256c848e53f57460fd39aa74cc64 100644 (file)
@@ -216,7 +216,7 @@ def test_is_sparse(check_scipy):
 
 
 def test_is_scipy_sparse():
-    sp_sparse = pytest.importorskip("scipy.sparse")
+    sp_sparse = td.versioned_importorskip("scipy.sparse")
 
     assert com.is_scipy_sparse(sp_sparse.bsr_matrix([1, 2, 3]))
 
index 79b7e6ff092b6efc519d8b29ad134c8019c6602f..0e8be5efb937f8847e10c1848ee1ec188b0def75 100644 (file)
@@ -28,6 +28,7 @@ import numpy as np
 import pytest
 import pytz
 
+import pandas.util._test_decorators as td
 from pandas._libs import (
     lib,
     missing as libmissing,
@@ -2009,7 +2010,7 @@ def test_nan_to_nat_conversions():
 
 @pytest.mark.filterwarnings("ignore::PendingDeprecationWarning")
 def test_is_scipy_sparse(spmatrix):
-    pytest.importorskip("scipy")
+    td.versioned_importorskip("scipy")
     assert is_scipy_sparse(spmatrix([[0, 1]]))
     assert not is_scipy_sparse(np.array([1]))
 
index 479497497a2ea3cfb1434da98469ceeeaa3565d6..f95f9a622f8040f9b4c11c194a6d3c31389d8eb1 100644 (file)
@@ -30,6 +30,7 @@ import re
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas._libs import lib
 from pandas._libs.tslibs import timezones
 from pandas.compat import (
@@ -63,7 +64,7 @@ from pandas.api.types import (
 )
 from pandas.tests.extension import base
 
-pa = pytest.importorskip("pyarrow")
+pa = td.versioned_importorskip("pyarrow")
 
 from pandas.core.arrays.arrow.array import ArrowExtensionArray
 from pandas.core.arrays.arrow.extension_types import ArrowPeriodType
index 71d4f7cc5c4bffcec673867f3675e4cfc1df2b3d..97ed4eb56dd0027437d08a54c715f8029581c4a2 100644 (file)
@@ -21,6 +21,7 @@ from typing import cast
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas.compat import HAS_PYARROW
 
 from pandas.core.dtypes.base import StorageExtensionDtype
@@ -40,7 +41,7 @@ def maybe_split_array(arr, chunked):
     elif arr.dtype.storage != "pyarrow":
         return arr
 
-    pa = pytest.importorskip("pyarrow")
+    pa = td.versioned_importorskip("pyarrow")
 
     arrow_array = arr._pa_array
     split = len(arrow_array) // 2
index 2c8456c6c06803d1f1bc6f51845014847fc6b034..1d2e8f16ae3441a9e2d845b4cd4d73556318554b 100644 (file)
@@ -779,7 +779,7 @@ class TestDataFrameSetItem:
 
     def test_setitem_string_option_object_index(self):
         # GH#55638
-        pytest.importorskip("pyarrow")
+        td.versioned_importorskip("pyarrow")
         df = DataFrame({"a": [1, 2]})
         with pd.option_context("future.infer_string", True):
             df["b"] = Index(["a", "b"], dtype=object)
index 938f9cfcde3f834a3788dff186cd0dfff3c093d1..cfc89eeffe88cfdc04602c0221ace7d71461dcf2 100644 (file)
@@ -897,7 +897,7 @@ def test_frame_astype_no_copy():
 @pytest.mark.parametrize("dtype", ["int64", "Int64"])
 def test_astype_copies(dtype):
     # GH#50984
-    pytest.importorskip("pyarrow")
+    td.versioned_importorskip("pyarrow")
     df = DataFrame({"a": [1, 2, 3]}, dtype=dtype)
     result = df.astype("int64[pyarrow]", copy=True)
     df.iloc[0, 0] = 100
index e7f6e5d625d3ece20131a5a719bf4f545b21a19b..f6c25015f6158daec0213e105f0f789ea455f566 100644 (file)
@@ -3,6 +3,7 @@ import datetime
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 import pandas as pd
 import pandas._testing as tm
 
@@ -45,7 +46,7 @@ class TestConvertDtypes:
         assert result.columns.name == "cols"
 
     def test_pyarrow_dtype_backend(self):
-        pa = pytest.importorskip("pyarrow")
+        pa = td.versioned_importorskip("pyarrow")
         df = pd.DataFrame(
             {
                 "a": pd.Series([1, 2, 3], dtype=np.dtype("int32")),
@@ -101,13 +102,13 @@ class TestConvertDtypes:
         tm.assert_frame_equal(result, expected)
 
     def test_pyarrow_dtype_backend_already_pyarrow(self):
-        pytest.importorskip("pyarrow")
+        td.versioned_importorskip("pyarrow")
         expected = pd.DataFrame([1, 2, 3], dtype="int64[pyarrow]")
         result = expected.convert_dtypes(dtype_backend="pyarrow")
         tm.assert_frame_equal(result, expected)
 
     def test_pyarrow_dtype_backend_from_pandas_nullable(self):
-        pa = pytest.importorskip("pyarrow")
+        pa = td.versioned_importorskip("pyarrow")
         df = pd.DataFrame(
             {
                 "a": pd.Series([1, 2, None], dtype="Int32"),
@@ -131,7 +132,7 @@ class TestConvertDtypes:
 
     def test_pyarrow_dtype_empty_object(self):
         # GH 50970
-        pytest.importorskip("pyarrow")
+        td.versioned_importorskip("pyarrow")
         expected = pd.DataFrame(columns=[0])
         result = expected.convert_dtypes(dtype_backend="pyarrow")
         tm.assert_frame_equal(result, expected)
@@ -148,7 +149,7 @@ class TestConvertDtypes:
 
     def test_pyarrow_backend_no_conversion(self):
         # GH#52872
-        pytest.importorskip("pyarrow")
+        td.versioned_importorskip("pyarrow")
         df = pd.DataFrame({"a": [1, 2], "b": 1.5, "c": True, "d": "x"})
         expected = df.copy()
         result = df.convert_dtypes(
@@ -162,7 +163,7 @@ class TestConvertDtypes:
 
     def test_convert_dtypes_pyarrow_to_np_nullable(self):
         # GH 53648
-        pytest.importorskip("pyarrow")
+        td.versioned_importorskip("pyarrow")
         ser = pd.DataFrame(range(2), dtype="int32[pyarrow]")
         result = ser.convert_dtypes(dtype_backend="numpy_nullable")
         expected = pd.DataFrame(range(2), dtype="Int32")
@@ -170,7 +171,7 @@ class TestConvertDtypes:
 
     def test_convert_dtypes_pyarrow_timestamp(self):
         # GH 54191
-        pytest.importorskip("pyarrow")
+        td.versioned_importorskip("pyarrow")
         ser = pd.Series(pd.date_range("2020-01-01", "2020-01-02", freq="1min"))
         expected = ser.astype("timestamp[ms][pyarrow]")
         result = expected.convert_dtypes(dtype_backend="pyarrow")
index 9abf1996c43e6bc262405a7d132986edc3219614..671db94783ff38577ad5094cd9b80979a3dd30c6 100644 (file)
@@ -105,7 +105,7 @@ class TestDataFrameCorr:
 
     @pytest.mark.parametrize("method", ["pearson", "kendall", "spearman"])
     def test_corr_scipy_method(self, float_frame, method):
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         float_frame.loc[float_frame.index[:5], "A"] = np.nan
         float_frame.loc[float_frame.index[5:10], "B"] = np.nan
         float_frame.loc[float_frame.index[:10], "A"] = float_frame["A"][10:20].copy()
@@ -126,7 +126,7 @@ class TestDataFrameCorr:
     @pytest.mark.parametrize("meth", ["pearson", "kendall", "spearman"])
     def test_corr_nooverlap(self, meth):
         # nothing in common
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         df = DataFrame(
             {
                 "A": [1, 1.5, 1, np.nan, np.nan, np.nan],
@@ -159,7 +159,7 @@ class TestDataFrameCorr:
         # when dtypes of pandas series are different
         # then ndarray will have dtype=object,
         # so it need to be properly handled
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         df = DataFrame({"a": [True, False], "b": [1, 0]})
 
         expected = DataFrame(np.ones((2, 2)), index=["a", "b"], columns=["a", "b"])
@@ -201,7 +201,7 @@ class TestDataFrameCorr:
     @pytest.mark.parametrize("method", ["pearson", "spearman", "kendall"])
     def test_corr_nullable_integer(self, nullable_column, other_column, method):
         # https://github.com/pandas-dev/pandas/issues/33803
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         data = DataFrame({"a": nullable_column, "b": other_column})
         result = data.corr(method=method)
         expected = DataFrame(np.ones((2, 2)), columns=["a", "b"], index=["a", "b"])
@@ -250,7 +250,7 @@ class TestDataFrameCorr:
 
     @pytest.mark.parametrize("method", ["pearson", "spearman", "kendall"])
     def test_corr_min_periods_greater_than_length(self, method):
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         df = DataFrame({"A": [1, 2], "B": [1, 2]})
         result = df.corr(method=method, min_periods=3)
         expected = DataFrame(
@@ -264,7 +264,7 @@ class TestDataFrameCorr:
         # when dtypes of pandas series are different
         # then ndarray will have dtype=object,
         # so it need to be properly handled
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         df = DataFrame({"a": [1, 0], "b": [1, 0], "c": ["x", "y"]})
         expected = DataFrame(np.ones((2, 2)), index=["a", "b"], columns=["a", "b"])
         if numeric_only:
@@ -432,7 +432,7 @@ class TestDataFrameCorrWith:
 
     def test_corrwith_spearman(self):
         # GH#21925
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         df = DataFrame(np.random.default_rng(2).random(size=(100, 3)))
         result = df.corrwith(df**2, method="spearman")
         expected = Series(np.ones(len(result)))
@@ -440,7 +440,7 @@ class TestDataFrameCorrWith:
 
     def test_corrwith_kendall(self):
         # GH#21925
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         df = DataFrame(np.random.default_rng(2).random(size=(100, 3)))
         result = df.corrwith(df**2, method="kendall")
         expected = Series(np.ones(len(result)))
@@ -448,7 +448,7 @@ class TestDataFrameCorrWith:
 
     def test_corrwith_spearman_with_tied_data(self):
         # GH#48826
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         df1 = DataFrame(
             {
                 "A": [1, np.nan, 7, 8],
index 5beb09940acf32a4a597819f5b130863d90261e5..f3ddeb17e794cb3d22740f2f2f0582c2d9d65d75 100644 (file)
@@ -1,6 +1,7 @@
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 import pandas as pd
 from pandas import (
     Categorical,
@@ -398,7 +399,7 @@ class TestDataFrameDescribe:
 
     def test_describe_exclude_pa_dtype(self):
         # GH#52570
-        pa = pytest.importorskip("pyarrow")
+        pa = td.versioned_importorskip("pyarrow")
         df = DataFrame(
             {
                 "a": Series([1, 2, 3], dtype=pd.ArrowDtype(pa.int8())),
index 3e01f67c8794bcf35d2b7be57f8bedcc06c2a137..995a6569c25bceaecd4b78ca0465914bf3865f39 100644 (file)
@@ -1,6 +1,7 @@
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas import (
     DataFrame,
     Series,
@@ -144,7 +145,7 @@ class TestDataFrameDot(DotSharedTests):
     [("Float32", "Float64"), ("Int16", "Int32"), ("float[pyarrow]", "double[pyarrow]")],
 )
 def test_arrow_dtype(dtype, exp_dtype):
-    pytest.importorskip("pyarrow")
+    td.versioned_importorskip("pyarrow")
 
     cols = ["a", "b"]
     df_a = DataFrame([[1, 2], [3, 4], [5, 6]], columns=cols, dtype="int32")
index c2d15e5ae88e83b9e2306ba3c4bb4435a739944e..7a3afb510c84bd81375764006e23e9a3c1de7c9f 100644 (file)
@@ -7,6 +7,7 @@ import textwrap
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas._config import using_string_dtype
 
 from pandas.compat import (
@@ -549,7 +550,7 @@ def test_memory_usage_empty_no_warning(using_infer_string):
 @pytest.mark.single_cpu
 def test_info_compute_numba():
     # GH#51922
-    numba = pytest.importorskip("numba")
+    numba = td.versioned_importorskip("numba")
     if Version(numba.__version__) == Version("0.61") and is_platform_arm():
         pytest.skip(f"Segfaults on ARM platforms with numba {numba.__version__}")
     df = DataFrame([[1, 2], [3, 4]])
index 214c7cb229f56cad27680a26264a562223e9660c..b8f7bc8709c59bba91c632fa085bdefdf33affba 100644 (file)
@@ -218,7 +218,7 @@ class TestDataFrameInterpolate:
             df.interpolate(method="values")
 
     def test_interp_various(self):
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         df = DataFrame(
             {"A": [1, 2, np.nan, 4, 5, np.nan, 7], "C": [1, 2, 3, 5, 8, 13, 21]}
         )
@@ -257,7 +257,7 @@ class TestDataFrameInterpolate:
         tm.assert_frame_equal(result, expected, check_dtype=False)
 
     def test_interp_alt_scipy(self):
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         df = DataFrame(
             {"A": [1, 2, np.nan, 4, 5, np.nan, 7], "C": [1, 2, 3, 5, 8, 13, 21]}
         )
@@ -549,7 +549,7 @@ class TestDataFrameInterpolate:
     )
     def test_interpolate_arrow(self, dtype):
         # GH#55347
-        pytest.importorskip("pyarrow")
+        td.versioned_importorskip("pyarrow")
         df = DataFrame({"a": [1, None, None, None, 3]}, dtype=dtype + "[pyarrow]")
         result = df.interpolate(limit=2)
         expected = DataFrame({"a": [1, 1.5, 2.0, None, 3]}, dtype="float64[pyarrow]")
index 735f6c50ab739dba04ebc49fec73cfa3147fc661..cd8c017a5207d22f81414218b23eb123b6fa31cc 100644 (file)
@@ -3,6 +3,7 @@ from datetime import datetime
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas.errors import MergeError
 
 import pandas as pd
@@ -163,7 +164,7 @@ def test_join_on_single_col_dup_on_right(left_no_dup, right_w_dups, dtype):
     # GH 46622
     # Dups on right allowed by one_to_many constraint
     if dtype == "string[pyarrow]":
-        pytest.importorskip("pyarrow")
+        td.versioned_importorskip("pyarrow")
     left_no_dup = left_no_dup.astype(dtype)
     right_w_dups.index = right_w_dups.index.astype(dtype)
     left_no_dup.join(
index 37bed2da0574305977dece25ce02771c4364d1de..9449455f48e5fe2eea8b4eb8fff470b923db889d 100644 (file)
@@ -6,6 +6,7 @@ from datetime import (
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas._libs.algos import (
     Infinity,
     NegInfinity,
@@ -39,7 +40,7 @@ class TestRank:
         return request.param
 
     def test_rank(self, float_frame):
-        sp_stats = pytest.importorskip("scipy.stats")
+        sp_stats = td.versioned_importorskip("scipy.stats")
 
         float_frame.loc[::2, "A"] = np.nan
         float_frame.loc[::3, "B"] = np.nan
@@ -143,7 +144,7 @@ class TestRank:
             float_string_frame.rank(axis=1)
 
     def test_rank_na_option(self, float_frame):
-        sp_stats = pytest.importorskip("scipy.stats")
+        sp_stats = td.versioned_importorskip("scipy.stats")
 
         float_frame.loc[::2, "A"] = np.nan
         float_frame.loc[::3, "B"] = np.nan
@@ -227,7 +228,7 @@ class TestRank:
     @pytest.mark.parametrize("ax", [0, 1])
     @pytest.mark.parametrize("m", ["average", "min", "max", "first", "dense"])
     def test_rank_methods_frame(self, ax, m):
-        sp_stats = pytest.importorskip("scipy.stats")
+        sp_stats = td.versioned_importorskip("scipy.stats")
 
         xs = np.random.default_rng(2).integers(0, 21, (100, 26))
         xs = (xs - 10.0) / 10.0
index 6c6944f806a2ae77b4a826684a9474769cd18e30..d1f43a98f5260e33e6e3488e5119b83be13c6a7a 100644 (file)
@@ -5,6 +5,7 @@ import pydoc
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas._config import using_string_dtype
 from pandas._config.config import option_context
 
@@ -292,7 +293,7 @@ class TestDataFrameMisc:
 
     def test_tab_complete_warning(self, ip, frame_or_series):
         # GH 16409
-        pytest.importorskip("IPython", minversion="6.0.0")
+        td.versioned_importorskip("IPython", min_version="6.0.0")
         from IPython.core.completer import provisionalcompleter
 
         if frame_or_series is DataFrame:
index b36b6b5ffe0cc3f843243a09cb08a2b74d6b728f..342dec76346b6d54231419d1af846d895d3778fe 100644 (file)
@@ -6,7 +6,7 @@ import pandas.util._test_decorators as td
 
 import pandas as pd
 
-pa = pytest.importorskip("pyarrow")
+pa = td.versioned_importorskip("pyarrow")
 
 
 @td.skip_if_no("pyarrow", min_version="14.0")
index efc40536d56beb94b5a3f72f36267bd15cc72702..d655cb9b65ba473320b5f4d9d657443c389d1a52 100644 (file)
@@ -2891,7 +2891,7 @@ class TestDataFrameConstructorIndexInference:
     )
     def test_dict_data_arrow_column_expansion(self, key_val, col_vals, col_type):
         # GH 53617
-        pa = pytest.importorskip("pyarrow")
+        pa = td.versioned_importorskip("pyarrow")
         cols = pd.arrays.ArrowExtensionArray(
             pa.array(col_vals, type=pa.dictionary(pa.int8(), getattr(pa, col_type)()))
         )
index ffabf238a4884d3b7436c890da77e2700dc8bde4..4b3866b333978658d067bff6fdb9d920924e5508 100644 (file)
@@ -1396,7 +1396,7 @@ class TestDataFrameQueryBacktickQuoting:
     @pytest.mark.parametrize("dtype", ["int64", "Int64", "int64[pyarrow]"])
     def test_query_ea_dtypes(self, dtype):
         if dtype == "int64[pyarrow]":
-            pytest.importorskip("pyarrow")
+            td.versioned_importorskip("pyarrow")
         # GH#50261
         df = DataFrame({"a": Series([1, 2], dtype=dtype)})
         ref = {2}  # noqa: F841
@@ -1414,7 +1414,7 @@ class TestDataFrameQueryBacktickQuoting:
         if engine == "numexpr" and not NUMEXPR_INSTALLED:
             pytest.skip("numexpr not installed")
         if dtype == "int64[pyarrow]":
-            pytest.importorskip("pyarrow")
+            td.versioned_importorskip("pyarrow")
         df = DataFrame(
             {"A": Series([1, 1, 2], dtype="Int64"), "B": Series([1, 2, 2], dtype=dtype)}
         )
index 2b025a4a8bb82afff67d7ad48ccef1b1b4b3d679..06019676f57371d98349a1b4cd922ce601aa54f7 100644 (file)
@@ -362,7 +362,7 @@ class TestDataFrameAnalytics:
         )
 
     def test_stat_op_calc_skew_kurtosis(self, float_frame_with_na):
-        sp_stats = pytest.importorskip("scipy.stats")
+        sp_stats = td.versioned_importorskip("scipy.stats")
 
         def skewness(x):
             if len(x) < 3:
@@ -1146,7 +1146,7 @@ class TestDataFrameAnalytics:
 
     def test_idxmax_arrow_types(self):
         # GH#55368
-        pytest.importorskip("pyarrow")
+        td.versioned_importorskip("pyarrow")
 
         df = DataFrame({"a": [2, 3, 1], "b": [2, 1, 1]}, dtype="int64[pyarrow]")
         result = df.idxmax()
@@ -1996,7 +1996,7 @@ def test_reduction_axis_none_returns_scalar(method, numeric_only, dtype):
     result = getattr(df, method)(axis=None, numeric_only=numeric_only)
     np_arr = df.to_numpy(dtype=np.float64)
     if method in {"skew", "kurt"}:
-        comp_mod = pytest.importorskip("scipy.stats")
+        comp_mod = td.versioned_importorskip("scipy.stats")
         if method == "kurt":
             method = "kurtosis"
         expected = getattr(comp_mod, method)(np_arr, bias=False, axis=None)
index 6184e791cab5d00f8a1057d142e4c63c3690615a..7fbc01a927f99da9060043e21ba77f49bdfe1302 100644 (file)
@@ -7,6 +7,7 @@ from io import StringIO
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas import (
     NA,
     Categorical,
@@ -284,7 +285,7 @@ NaT   4"""
             assert "StringCol" in repr(df)
 
     def test_latex_repr(self):
-        pytest.importorskip("jinja2")
+        td.versioned_importorskip("jinja2")
         expected = r"""\begin{tabular}{llll}
 \toprule
  & 0 & 1 & 2 \\
@@ -472,7 +473,7 @@ NaT   4"""
 
     def test_repr_ea_columns(self, any_string_dtype):
         # GH#54797
-        pytest.importorskip("pyarrow")
+        td.versioned_importorskip("pyarrow")
         df = DataFrame({"long_column_name": [1, 2, 3], "col2": [4, 5, 6]})
         df.columns = df.columns.astype(any_string_dtype)
         expected = """   long_column_name  col2
index 39a29406c6e9a0d2e7b3b188314f51d2d721d5b5..dc60e6f693485eb2206a1ececfa3a772969fd714 100644 (file)
@@ -1,6 +1,7 @@
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 import pandas as pd
 from pandas import (
     DataFrame,
@@ -669,7 +670,7 @@ class TestDataFrameSubclassing:
         assert isinstance(result, tm.SubclassedSeries)
 
     def test_corrwith(self):
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         index = ["a", "b", "c", "d", "e"]
         columns = ["one", "two", "three", "four"]
         df1 = tm.SubclassedDataFrame(
index 88c62da2b0a735b103f7a6b03634aa185fc46d2c..53256cf0d565ac1b150ed6fcb285595ce88e8c2c 100644 (file)
@@ -4,6 +4,7 @@ import re
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 import pandas as pd
 import pandas._testing as tm
 from pandas.api.types import is_extension_array_dtype
@@ -250,7 +251,7 @@ def test_alignment_deprecation_many_inputs_enforced():
     # https://github.com/pandas-dev/pandas/issues/39184
     # test that the deprecation also works with > 2 inputs -> using a numba
     # written ufunc for this because numpy itself doesn't have such ufuncs
-    numba = pytest.importorskip("numba")
+    numba = td.versioned_importorskip("numba")
 
     @numba.vectorize([numba.float64(numba.float64, numba.float64, numba.float64)])
     def my_ufunc(x, y, z):
index 866e9e203ffe3ac1fe29d86b87bbacccf1268e12..d07931478b3a291aec053ca8535317e2f4013b7b 100644 (file)
@@ -7,6 +7,7 @@ import re
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 import pandas as pd
 import pandas._testing as tm
 
@@ -443,7 +444,7 @@ def test_finalize_last(data):
 
 @not_implemented_mark
 def test_finalize_called_eval_numexpr():
-    pytest.importorskip("numexpr")
+    td.versioned_importorskip("numexpr")
     df = pd.DataFrame({"A": [1, 2]})
     df.attrs["A"] = 1
     result = df.eval("A + 1", engine="numexpr")
index 9b589c9348c35f763da12bff03e196062d11564b..e882a3b7115294fa839c12075ab11d6ff14bdfd5 100644 (file)
@@ -1,6 +1,7 @@
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas import (
     Categorical,
     DataFrame,
@@ -12,7 +13,7 @@ from pandas import (
 import pandas._testing as tm
 from pandas.util.version import Version
 
-xarray = pytest.importorskip("xarray")
+xarray = td.versioned_importorskip("xarray")
 
 
 class TestDataFrameToXArray:
index 166739c930f0a2f312b4fa861ac13da5be9b8d3f..4bf1e9a4ac72ce2c153079e717c88d7c6b419456 100644 (file)
@@ -1,6 +1,7 @@
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas.compat import is_platform_arm
 from pandas.errors import NumbaUtilError
 
@@ -22,7 +23,7 @@ except ImportError:  # numba not installed
 
 pytestmark = [pytest.mark.single_cpu]
 
-numba = pytest.importorskip("numba")
+numba = td.versioned_importorskip("numba")
 pytestmark.append(
     pytest.mark.skipif(
         Version(numba.__version__) == Version("0.61") and is_platform_arm(),
@@ -32,7 +33,7 @@ pytestmark.append(
 
 
 def test_correct_function_signature():
-    pytest.importorskip("numba")
+    td.versioned_importorskip("numba")
 
     def incorrect_function(x):
         return sum(x) * 2.7
@@ -49,7 +50,7 @@ def test_correct_function_signature():
 
 
 def test_check_nopython_kwargs():
-    pytest.importorskip("numba")
+    td.versioned_importorskip("numba")
 
     def incorrect_function(values, index):
         return sum(values) * 2.7
@@ -71,7 +72,7 @@ def test_check_nopython_kwargs():
 @pytest.mark.parametrize("pandas_obj", ["Series", "DataFrame"])
 @pytest.mark.parametrize("as_index", [True, False])
 def test_numba_vs_cython(jit, pandas_obj, nogil, parallel, nopython, as_index):
-    pytest.importorskip("numba")
+    td.versioned_importorskip("numba")
 
     def func_numba(values, index):
         return np.mean(values) * 2.7
@@ -102,7 +103,7 @@ def test_numba_vs_cython(jit, pandas_obj, nogil, parallel, nopython, as_index):
 @pytest.mark.parametrize("pandas_obj", ["Series", "DataFrame"])
 def test_cache(jit, pandas_obj, nogil, parallel, nopython):
     # Test that the functions are cached correctly if we switch functions
-    pytest.importorskip("numba")
+    td.versioned_importorskip("numba")
 
     def func_1(values, index):
         return np.mean(values) - 3.4
@@ -140,7 +141,7 @@ def test_cache(jit, pandas_obj, nogil, parallel, nopython):
 
 
 def test_use_global_config():
-    pytest.importorskip("numba")
+    td.versioned_importorskip("numba")
 
     def func_1(values, index):
         return np.mean(values) - 3.4
@@ -165,7 +166,7 @@ def test_use_global_config():
     ],
 )
 def test_multifunc_numba_vs_cython_frame(agg_kwargs):
-    pytest.importorskip("numba")
+    td.versioned_importorskip("numba")
     data = DataFrame(
         {
             0: ["a", "a", "b", "b", "a"],
@@ -200,7 +201,7 @@ def test_multifunc_numba_vs_cython_frame(agg_kwargs):
     ],
 )
 def test_multifunc_numba_udf_frame(agg_kwargs, expected_func):
-    pytest.importorskip("numba")
+    td.versioned_importorskip("numba")
     data = DataFrame(
         {
             0: ["a", "a", "b", "b", "a"],
@@ -222,7 +223,7 @@ def test_multifunc_numba_udf_frame(agg_kwargs, expected_func):
     [{"func": ["min", "max"]}, {"func": "min"}, {"min_val": "min", "max_val": "max"}],
 )
 def test_multifunc_numba_vs_cython_series(agg_kwargs):
-    pytest.importorskip("numba")
+    td.versioned_importorskip("numba")
     labels = ["a", "a", "b", "b", "a"]
     data = Series([1.0, 2.0, 3.0, 4.0, 5.0])
     grouped = data.groupby(labels)
@@ -275,7 +276,7 @@ def test_multifunc_numba_vs_cython_series(agg_kwargs):
     strict=False,
 )
 def test_multifunc_numba_kwarg_propagation(data, agg_kwargs):
-    pytest.importorskip("numba")
+    td.versioned_importorskip("numba")
     labels = ["a", "a", "b", "b", "a"]
     grouped = data.groupby(labels)
     result = grouped.agg(**agg_kwargs, engine="numba", engine_kwargs={"parallel": True})
@@ -288,7 +289,7 @@ def test_multifunc_numba_kwarg_propagation(data, agg_kwargs):
 
 def test_args_not_cached():
     # GH 41647
-    pytest.importorskip("numba")
+    td.versioned_importorskip("numba")
 
     def sum_last(values, index, n):
         return values[-n:].sum()
@@ -306,7 +307,7 @@ def test_args_not_cached():
 
 def test_index_data_correctly_passed():
     # GH 43133
-    pytest.importorskip("numba")
+    td.versioned_importorskip("numba")
 
     def f(values, index):
         return np.mean(index)
@@ -322,7 +323,7 @@ def test_index_data_correctly_passed():
 def test_engine_kwargs_not_cached():
     # If the user passes a different set of engine_kwargs don't return the same
     # jitted function
-    pytest.importorskip("numba")
+    td.versioned_importorskip("numba")
     nogil = True
     parallel = False
     nopython = True
@@ -349,7 +350,7 @@ def test_engine_kwargs_not_cached():
 
 @pytest.mark.filterwarnings("ignore")
 def test_multiindex_one_key(nogil, parallel, nopython):
-    pytest.importorskip("numba")
+    td.versioned_importorskip("numba")
 
     def numba_func(values, index):
         return 1
@@ -364,7 +365,7 @@ def test_multiindex_one_key(nogil, parallel, nopython):
 
 
 def test_multiindex_multi_key_not_supported(nogil, parallel, nopython):
-    pytest.importorskip("numba")
+    td.versioned_importorskip("numba")
 
     def numba_func(values, index):
         return 1
@@ -378,7 +379,7 @@ def test_multiindex_multi_key_not_supported(nogil, parallel, nopython):
 
 
 def test_multilabel_numba_vs_cython(numba_supported_reductions):
-    pytest.importorskip("numba")
+    td.versioned_importorskip("numba")
     reduction, kwargs = numba_supported_reductions
     df = DataFrame(
         {
@@ -399,7 +400,7 @@ def test_multilabel_numba_vs_cython(numba_supported_reductions):
 
 
 def test_multilabel_udf_numba_vs_cython():
-    pytest.importorskip("numba")
+    td.versioned_importorskip("numba")
     df = DataFrame(
         {
             "A": ["foo", "bar", "foo", "bar", "foo", "bar", "foo", "foo"],
index 16d7fe61b90ad3eece2d16345407d21fbece6962..656cba9b3c80f432f93e102b185cb25de86de3bc 100644 (file)
@@ -4,6 +4,7 @@ from string import ascii_lowercase
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas import (
     DataFrame,
     Index,
@@ -385,7 +386,7 @@ def test_count_uses_size_on_exception():
 
 def test_count_arrow_string_array(any_string_dtype):
     # GH#54751
-    pytest.importorskip("pyarrow")
+    td.versioned_importorskip("pyarrow")
     df = DataFrame(
         {"a": [1, 2, 3], "b": Series(["a", "b", "a"], dtype=any_string_dtype)}
     )
index 3e25c44e4580c840d60aac9645465288d6607371..ae6d44ac2a9e05055e8ca28b7e194cecce9e027d 100644 (file)
@@ -2613,7 +2613,7 @@ def test_groupby_column_index_name_lost(func):
 def test_groupby_duplicate_columns(infer_string):
     # GH: 31735
     if infer_string:
-        pytest.importorskip("pyarrow")
+        td.versioned_importorskip("pyarrow")
     df = DataFrame(
         {"A": ["f", "e", "g", "h"], "B": ["a", "b", "c", "d"], "C": [1, 2, 3, 4]}
     ).astype(object)
index f2c138c86a046a27c93e402d4864d1351275c317..b9da9c0c18c9df589cd281f9b2bebe46b5441409 100644 (file)
@@ -1,5 +1,6 @@
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas.compat import is_platform_arm
 
 from pandas import (
@@ -12,7 +13,7 @@ from pandas.util.version import Version
 
 pytestmark = [pytest.mark.single_cpu]
 
-numba = pytest.importorskip("numba")
+numba = td.versioned_importorskip("numba")
 pytestmark.append(
     pytest.mark.skipif(
         Version(numba.__version__) == Version("0.61") and is_platform_arm(),
index 3c1ed20ddcb165db2444146c3e13ce7d7a8f874a..651a06789faeedfc4cdcdeb520240b76ae625b98 100644 (file)
@@ -3,6 +3,7 @@ import re
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas._libs import lib
 
 import pandas as pd
@@ -282,7 +283,7 @@ def test_axis1_numeric_only(request, groupby_func, numeric_only, using_infer_str
             "operation 'sub' not supported for dtype 'str' with dtype 'float64'",
         )
         if using_infer_string:
-            pa = pytest.importorskip("pyarrow")
+            pa = td.versioned_importorskip("pyarrow")
 
             errs = (TypeError, pa.lib.ArrowNotImplementedError)
         else:
index 0dc2e84c559532e73fc18fa389614ca988fd4f17..64ecf7fe6573be545667d61ce70dbcf5d7c82225 100644 (file)
@@ -10,6 +10,7 @@ import numpy as np
 import pytest
 import pytz
 
+import pandas.util._test_decorators as td
 import pandas as pd
 from pandas import (
     DataFrame,
@@ -946,7 +947,7 @@ class TestGroupBy:
     def test_groupby_agg_numba_timegrouper_with_nat(
         self, groupby_with_truncated_bingrouper
     ):
-        pytest.importorskip("numba")
+        td.versioned_importorskip("numba")
 
         # See discussion in GH#43487
         gb = groupby_with_truncated_bingrouper
index 5afc6f3bdcd3c223157f05801d2ec83432f80d47..dde1f946ee14cd8d52a12cd0a94f8c7a9f727424 100644 (file)
@@ -1,6 +1,7 @@
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas.compat import is_platform_arm
 from pandas.errors import NumbaUtilError
 
@@ -14,7 +15,7 @@ from pandas.util.version import Version
 
 pytestmark = [pytest.mark.single_cpu]
 
-numba = pytest.importorskip("numba")
+numba = td.versioned_importorskip("numba")
 pytestmark.append(
     pytest.mark.skipif(
         Version(numba.__version__) == Version("0.61") and is_platform_arm(),
@@ -24,7 +25,7 @@ pytestmark.append(
 
 
 def test_correct_function_signature():
-    pytest.importorskip("numba")
+    td.versioned_importorskip("numba")
 
     def incorrect_function(x):
         return x + 1
@@ -41,7 +42,7 @@ def test_correct_function_signature():
 
 
 def test_check_nopython_kwargs():
-    pytest.importorskip("numba")
+    td.versioned_importorskip("numba")
 
     def incorrect_function(values, index):
         return values + 1
@@ -63,7 +64,7 @@ def test_check_nopython_kwargs():
 @pytest.mark.parametrize("pandas_obj", ["Series", "DataFrame"])
 @pytest.mark.parametrize("as_index", [True, False])
 def test_numba_vs_cython(jit, pandas_obj, nogil, parallel, nopython, as_index):
-    pytest.importorskip("numba")
+    td.versioned_importorskip("numba")
 
     def func(values, index):
         return values + 1
@@ -94,7 +95,7 @@ def test_numba_vs_cython(jit, pandas_obj, nogil, parallel, nopython, as_index):
 @pytest.mark.parametrize("pandas_obj", ["Series", "DataFrame"])
 def test_cache(jit, pandas_obj, nogil, parallel, nopython):
     # Test that the functions are cached correctly if we switch functions
-    pytest.importorskip("numba")
+    td.versioned_importorskip("numba")
 
     def func_1(values, index):
         return values + 1
@@ -131,7 +132,7 @@ def test_cache(jit, pandas_obj, nogil, parallel, nopython):
 
 
 def test_use_global_config():
-    pytest.importorskip("numba")
+    td.versioned_importorskip("numba")
 
     def func_1(values, index):
         return values + 1
@@ -151,7 +152,7 @@ def test_use_global_config():
     "agg_func", [["min", "max"], "min", {"B": ["min", "max"], "C": "sum"}]
 )
 def test_string_cython_vs_numba(agg_func, numba_supported_reductions):
-    pytest.importorskip("numba")
+    td.versioned_importorskip("numba")
     agg_func, kwargs = numba_supported_reductions
     data = DataFrame(
         {0: ["a", "a", "b", "b", "a"], 1: [1.0, 2.0, 3.0, 4.0, 5.0]}, columns=[0, 1]
@@ -169,7 +170,7 @@ def test_string_cython_vs_numba(agg_func, numba_supported_reductions):
 
 def test_args_not_cached():
     # GH 41647
-    pytest.importorskip("numba")
+    td.versioned_importorskip("numba")
 
     def sum_last(values, index, n):
         return values[-n:].sum()
@@ -187,7 +188,7 @@ def test_args_not_cached():
 
 def test_index_data_correctly_passed():
     # GH 43133
-    pytest.importorskip("numba")
+    td.versioned_importorskip("numba")
 
     def f(values, index):
         return index - 1
@@ -201,7 +202,7 @@ def test_index_data_correctly_passed():
 def test_engine_kwargs_not_cached():
     # If the user passes a different set of engine_kwargs don't return the same
     # jitted function
-    pytest.importorskip("numba")
+    td.versioned_importorskip("numba")
     nogil = True
     parallel = False
     nopython = True
@@ -228,7 +229,7 @@ def test_engine_kwargs_not_cached():
 
 @pytest.mark.filterwarnings("ignore")
 def test_multiindex_one_key(nogil, parallel, nopython):
-    pytest.importorskip("numba")
+    td.versioned_importorskip("numba")
 
     def numba_func(values, index):
         return 1
@@ -243,7 +244,7 @@ def test_multiindex_one_key(nogil, parallel, nopython):
 
 
 def test_multiindex_multi_key_not_supported(nogil, parallel, nopython):
-    pytest.importorskip("numba")
+    td.versioned_importorskip("numba")
 
     def numba_func(values, index):
         return 1
@@ -257,7 +258,7 @@ def test_multiindex_multi_key_not_supported(nogil, parallel, nopython):
 
 
 def test_multilabel_numba_vs_cython(numba_supported_reductions):
-    pytest.importorskip("numba")
+    td.versioned_importorskip("numba")
     reduction, kwargs = numba_supported_reductions
     df = DataFrame(
         {
@@ -274,7 +275,7 @@ def test_multilabel_numba_vs_cython(numba_supported_reductions):
 
 
 def test_multilabel_udf_numba_vs_cython():
-    pytest.importorskip("numba")
+    td.versioned_importorskip("numba")
     df = DataFrame(
         {
             "A": ["foo", "bar", "foo", "bar", "foo", "bar", "foo", "foo"],
index b1180f2d7af145dd30592925bfd16a4c2484a88f..bb96cbfae2d11848da88db406caacf285c535e21 100644 (file)
@@ -7,6 +7,7 @@ import itertools
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas.core.dtypes.cast import construct_1d_object_array_from_listlike
 
 import pandas as pd
@@ -648,7 +649,7 @@ def test_from_frame():
 
 def test_from_frame_missing_values_multiIndex():
     # GH 39984
-    pa = pytest.importorskip("pyarrow")
+    pa = td.versioned_importorskip("pyarrow")
 
     df = pd.DataFrame(
         {
index cd28d519313ed36228040361dfbb2a8dccf77be5..f53d55571b658c306b423ec0d28dc82e55de4ed0 100644 (file)
@@ -1,6 +1,7 @@
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas.errors import InvalidIndexError
 
 from pandas import (
@@ -385,7 +386,7 @@ class TestGetIndexer:
     def test_get_indexer_masked_na_boolean(self, dtype):
         # GH#39133
         if dtype == "bool[pyarrow]":
-            pytest.importorskip("pyarrow")
+            td.versioned_importorskip("pyarrow")
         idx = Index([True, False, NA], dtype=dtype)
         result = idx.get_loc(False)
         assert result == 1
@@ -393,7 +394,7 @@ class TestGetIndexer:
         assert result == 2
 
     def test_get_indexer_arrow_dictionary_target(self):
-        pa = pytest.importorskip("pyarrow")
+        pa = td.versioned_importorskip("pyarrow")
         target = Index(
             ArrowExtensionArray(
                 pa.array([1, 2], type=pa.dictionary(pa.int8(), pa.int8()))
index a94e4728a975174ac0663898fd812c6de7775936..daf652d75d04c3b2b093def1d65e7de60a2afeee 100644 (file)
@@ -1282,7 +1282,7 @@ class TestIndex:
 
     def test_tab_complete_warning(self, ip):
         # https://github.com/pandas-dev/pandas/issues/16409
-        pytest.importorskip("IPython", minversion="6.0.0")
+        td.versioned_importorskip("IPython", min_version="6.0.0")
         from IPython.core.completer import provisionalcompleter
 
         code = "import pandas as pd; idx = pd.Index([1, 2])"
index af7533399ea74afb5a5d2b14d2d37d2194926114..bb551127c9367edeb4c466e0dc357fc6494d05f7 100644 (file)
@@ -2,6 +2,7 @@ import re
 
 import pytest
 
+import pandas.util._test_decorators as td
 import pandas as pd
 from pandas import (
     DataFrame,
@@ -174,7 +175,7 @@ class TestDatetimeIndex:
 
     def test_getitem_pyarrow_index(self, frame_or_series):
         # GH 53644
-        pytest.importorskip("pyarrow")
+        td.versioned_importorskip("pyarrow")
         obj = frame_or_series(
             range(5),
             index=date_range("2020", freq="D", periods=5).astype(
index a26bf15d0ff39372fb621bd593f69e66fb4d0c7f..cbad5dec4a5f838f8dbe50d7ebc20de490e55174 100644 (file)
@@ -1342,7 +1342,7 @@ class TestLocBaseIndependent:
     @pytest.mark.parametrize("spmatrix_t", ["coo_matrix", "csc_matrix", "csr_matrix"])
     @pytest.mark.parametrize("dtype", [np.int64, np.float64, complex])
     def test_loc_getitem_range_from_spmatrix(self, spmatrix_t, dtype):
-        sp_sparse = pytest.importorskip("scipy.sparse")
+        sp_sparse = td.versioned_importorskip("scipy.sparse")
 
         spmatrix_t = getattr(sp_sparse, spmatrix_t)
 
@@ -1371,7 +1371,7 @@ class TestLocBaseIndependent:
 
     def test_loc_getitem_sparse_frame(self):
         # GH34687
-        sp_sparse = pytest.importorskip("scipy.sparse")
+        sp_sparse = td.versioned_importorskip("scipy.sparse")
 
         df = DataFrame.sparse.from_spmatrix(sp_sparse.eye(5))
         result = df.loc[range(2)]
@@ -3123,7 +3123,7 @@ def test_loc_periodindex_3_levels():
 
 def test_loc_setitem_pyarrow_strings():
     # GH#52319
-    pytest.importorskip("pyarrow")
+    td.versioned_importorskip("pyarrow")
     df = DataFrame(
         {
             "strings": Series(["A", "B", "C"], dtype="string[pyarrow]"),
index 5563ee8b4caed45bea14ddebaf4ad41f2b846ea6..407a5b9be7112837259ad1cf9e1ed6a75376d03b 100644 (file)
@@ -6,6 +6,7 @@ from datetime import (
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas._libs.tslibs import iNaT
 from pandas.compat import (
     is_ci_environment,
@@ -67,7 +68,7 @@ def test_categorical_dtype(data, data_categorical):
 
 def test_categorical_pyarrow():
     # GH 49889
-    pa = pytest.importorskip("pyarrow", "11.0.0")
+    pa = td.versioned_importorskip("pyarrow", "11.0.0")
 
     arr = ["Mon", "Tue", "Mon", "Wed", "Mon", "Thu", "Fri", "Sat", "Sun"]
     table = pa.table({"weekday": pa.array(arr).dictionary_encode()})
@@ -82,7 +83,7 @@ def test_categorical_pyarrow():
 
 def test_empty_categorical_pyarrow():
     # https://github.com/pandas-dev/pandas/issues/53077
-    pa = pytest.importorskip("pyarrow", "11.0.0")
+    pa = td.versioned_importorskip("pyarrow", "11.0.0")
 
     arr = [None]
     table = pa.table({"arr": pa.array(arr, "float64").dictionary_encode()})
@@ -94,7 +95,7 @@ def test_empty_categorical_pyarrow():
 
 def test_large_string_pyarrow():
     # GH 52795
-    pa = pytest.importorskip("pyarrow", "11.0.0")
+    pa = td.versioned_importorskip("pyarrow", "11.0.0")
 
     arr = ["Mon", "Tue"]
     table = pa.table({"weekday": pa.array(arr, "large_string")})
@@ -120,7 +121,7 @@ def test_large_string_pyarrow():
 )
 def test_bitmasks_pyarrow(offset, length, expected_values):
     # GH 52795
-    pa = pytest.importorskip("pyarrow", "11.0.0")
+    pa = td.versioned_importorskip("pyarrow", "11.0.0")
 
     arr = [3.3, None, 2.1]
     table = pa.table({"arr": arr}).slice(offset, length)
@@ -282,7 +283,7 @@ def test_categorical_to_numpy_dlpack():
 @pytest.mark.parametrize("data", [{}, {"a": []}])
 def test_empty_pyarrow(data):
     # GH 53155
-    pytest.importorskip("pyarrow", "11.0.0")
+    td.versioned_importorskip("pyarrow", "11.0.0")
     from pyarrow.interchange import from_dataframe as pa_from_dataframe
 
     expected = pd.DataFrame(data)
@@ -292,7 +293,7 @@ def test_empty_pyarrow(data):
 
 
 def test_multi_chunk_pyarrow() -> None:
-    pa = pytest.importorskip("pyarrow", "11.0.0")
+    pa = td.versioned_importorskip("pyarrow", "11.0.0")
     n_legs = pa.chunked_array([[2, 2, 4], [4, 5, 100]])
     names = ["n_legs"]
     table = pa.table([n_legs], names=names)
@@ -304,7 +305,7 @@ def test_multi_chunk_pyarrow() -> None:
 
 
 def test_multi_chunk_column() -> None:
-    pytest.importorskip("pyarrow", "11.0.0")
+    td.versioned_importorskip("pyarrow", "11.0.0")
     ser = pd.Series([1, 2, None], dtype="Int64[pyarrow]")
     df = pd.concat([ser, ser], ignore_index=True).to_frame("a")
     df_orig = df.copy()
@@ -326,7 +327,7 @@ def test_multi_chunk_column() -> None:
 
 def test_timestamp_ns_pyarrow():
     # GH 56712
-    pytest.importorskip("pyarrow", "11.0.0")
+    td.versioned_importorskip("pyarrow", "11.0.0")
     timestamp_args = {
         "year": 2000,
         "month": 1,
@@ -361,7 +362,7 @@ def test_datetimetzdtype(tz, unit):
 
 def test_interchange_from_non_pandas_tz_aware(request):
     # GH 54239, 54287
-    pa = pytest.importorskip("pyarrow", "11.0.0")
+    pa = td.versioned_importorskip("pyarrow", "11.0.0")
     import pyarrow.compute as pc
 
     if is_platform_windows() and is_ci_environment():
@@ -419,7 +420,7 @@ def test_empty_string_column():
 
 def test_large_string():
     # GH#56702
-    pytest.importorskip("pyarrow")
+    td.versioned_importorskip("pyarrow")
     df = pd.DataFrame({"a": ["x"]}, dtype="large_string[pyarrow]")
     result = pd.api.interchange.from_dataframe(df.__dataframe__())
     expected = pd.DataFrame({"a": ["x"]}, dtype="str")
@@ -499,7 +500,7 @@ def test_pandas_nullable_with_missing_values(
 ) -> None:
     # https://github.com/pandas-dev/pandas/issues/57643
     # https://github.com/pandas-dev/pandas/issues/57664
-    pa = pytest.importorskip("pyarrow", "11.0.0")
+    pa = td.versioned_importorskip("pyarrow", "11.0.0")
     import pyarrow.interchange as pai
 
     if expected_dtype == "timestamp[us, tz=Asia/Kathmandu]":
@@ -565,7 +566,7 @@ def test_pandas_nullable_without_missing_values(
     data: list, dtype: str, expected_dtype: str
 ) -> None:
     # https://github.com/pandas-dev/pandas/issues/57643
-    pa = pytest.importorskip("pyarrow", "11.0.0")
+    pa = td.versioned_importorskip("pyarrow", "11.0.0")
     import pyarrow.interchange as pai
 
     if expected_dtype == "timestamp[us, tz=Asia/Kathmandu]":
@@ -581,7 +582,7 @@ def test_pandas_nullable_without_missing_values(
 
 def test_string_validity_buffer() -> None:
     # https://github.com/pandas-dev/pandas/issues/57761
-    pytest.importorskip("pyarrow", "11.0.0")
+    td.versioned_importorskip("pyarrow", "11.0.0")
     df = pd.DataFrame({"a": ["x"]}, dtype="large_string[pyarrow]")
     result = df.__dataframe__().get_column_by_name("a").get_buffers()["validity"]
     assert result is None
@@ -589,7 +590,7 @@ def test_string_validity_buffer() -> None:
 
 def test_string_validity_buffer_no_missing() -> None:
     # https://github.com/pandas-dev/pandas/issues/57762
-    pytest.importorskip("pyarrow", "11.0.0")
+    td.versioned_importorskip("pyarrow", "11.0.0")
     df = pd.DataFrame({"a": ["x", None]}, dtype="large_string[pyarrow]")
     validity = df.__dataframe__().get_column_by_name("a").get_buffers()["validity"]
     assert validity is not None
@@ -608,7 +609,7 @@ def test_empty_dataframe():
 
 
 def test_from_dataframe_list_dtype():
-    pa = pytest.importorskip("pyarrow", "14.0.0")
+    pa = td.versioned_importorskip("pyarrow", "14.0.0")
     data = {"a": [[1, 2], [4, 5, 6]]}
     tbl = pa.table(data)
     result = from_dataframe(tbl)
index a47bc2752ff32f5eb7630a3960e7611242cb73e3..47b2fd65d381ec02570af91d70492593da796c9a 100644 (file)
@@ -1,6 +1,7 @@
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 import pandas as pd
 from pandas.core.interchange.utils import dtype_to_arrow_c_fmt
 
@@ -78,7 +79,7 @@ def test_dtype_to_arrow_c_fmt(pandas_dtype, c_string):  # PR01
 )
 def test_dtype_to_arrow_c_fmt_arrowdtype(pa_dtype, args_kwargs, c_string):
     # GH 52323
-    pa = pytest.importorskip("pyarrow")
+    pa = td.versioned_importorskip("pyarrow")
     if not args_kwargs:
         pa_type = getattr(pa, pa_dtype)()
     elif isinstance(args_kwargs, tuple):
index a5ddda9d66e7af4a418a65650f1f44ae35bec4a1..9888a7ee3cc739f2e4758588f12d433adc788919 100644 (file)
@@ -58,8 +58,8 @@ def s3_base(worker_id, monkeypatch):
     Sets up moto server in separate process locally
     Return url for motoserver/moto CI service
     """
-    pytest.importorskip("s3fs")
-    pytest.importorskip("boto3")
+    td.versioned_importorskip("s3fs")
+    td.versioned_importorskip("boto3")
 
     # temporary workaround as moto fails for botocore >= 1.11 otherwise,
     # see https://github.com/spulec/moto/issues/1924 & 1952
@@ -79,9 +79,9 @@ def s3_base(worker_id, monkeypatch):
             # set in .github/workflows/unit-tests.yml
             yield "http://localhost:5000"
     else:
-        requests = pytest.importorskip("requests")
-        pytest.importorskip("moto")
-        pytest.importorskip("flask")  # server mode needs flask too
+        requests = td.versioned_importorskip("requests")
+        td.versioned_importorskip("moto")
+        td.versioned_importorskip("flask")  # server mode needs flask too
 
         # Launching moto in server mode, i.e., as a separate process
         # with an S3 endpoint on localhost
index b5bb9b27258d86cda6e44aeae17a4cdba4157a43..7e2f0e8b936afe79ac46e0177262928f5a36b351 100644 (file)
@@ -3,12 +3,13 @@ import functools
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas.compat import is_platform_windows
 
 import pandas as pd
 import pandas._testing as tm
 
-pytest.importorskip("odf")
+td.versioned_importorskip("odf")
 
 if is_platform_windows():
     pytestmark = pytest.mark.single_cpu
index 1c728ad801bc139c1ca1cd2e902884a5a2c91ffc..a20193a347cfb6bca95304f1ffffbcf84581cac7 100644 (file)
@@ -6,6 +6,7 @@ import re
 
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas.compat import is_platform_windows
 
 import pandas as pd
@@ -13,7 +14,7 @@ import pandas._testing as tm
 
 from pandas.io.excel import ExcelWriter
 
-odf = pytest.importorskip("odf")
+odf = td.versioned_importorskip("odf")
 
 if is_platform_windows():
     pytestmark = pytest.mark.single_cpu
index 99c19638eaece3f971b97499729253587b258a13..3fbb4bce17dc5a3e98c8a644fc8aff9cf1e0d653 100644 (file)
@@ -5,6 +5,7 @@ import re
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas.compat import is_platform_windows
 
 import pandas as pd
@@ -17,7 +18,7 @@ from pandas.io.excel import (
 )
 from pandas.io.excel._openpyxl import OpenpyxlReader
 
-openpyxl = pytest.importorskip("openpyxl")
+openpyxl = td.versioned_importorskip("openpyxl")
 
 if is_platform_windows():
     pytestmark = pytest.mark.single_cpu
index 89615172688d7b56fbb070dbcd4750365d7d612d..f0c093b3d5f28398d5aa98cc46a3ae6fe8b8405a 100644 (file)
@@ -16,7 +16,7 @@ import pandas._testing as tm
 from pandas.io.excel import ExcelWriter
 from pandas.io.formats.excel import ExcelFormatter
 
-pytest.importorskip("jinja2")
+td.versioned_importorskip("jinja2")
 # jinja2 is currently required for Styler.__init__(). Technically Styler.to_excel
 # could compute styles and render to excel without jinja2, since there is no
 # 'template' file, but this needs the import error to delayed until render time.
@@ -41,14 +41,14 @@ def assert_equal_cell_styles(cell1, cell2):
 )
 def test_styler_to_excel_unstyled(engine):
     # compare DataFrame.to_excel and Styler.to_excel when no styles applied
-    pytest.importorskip(engine)
+    td.versioned_importorskip(engine)
     df = DataFrame(np.random.default_rng(2).standard_normal((2, 2)))
     with tm.ensure_clean(".xlsx") as path:
         with ExcelWriter(path, engine=engine) as writer:
             df.to_excel(writer, sheet_name="dataframe")
             df.style.to_excel(writer, sheet_name="unstyled")
 
-        openpyxl = pytest.importorskip("openpyxl")  # test loading only with openpyxl
+        openpyxl = td.versioned_importorskip("openpyxl")  # test loading only with openpyxl
         with contextlib.closing(openpyxl.load_workbook(path)) as wb:
             for col1, col2 in zip(wb["dataframe"].columns, wb["unstyled"].columns):
                 assert len(col1) == len(col2)
@@ -133,7 +133,7 @@ shared_style_params = [
 )
 @pytest.mark.parametrize("css, attrs, expected", shared_style_params)
 def test_styler_to_excel_basic(engine, css, attrs, expected):
-    pytest.importorskip(engine)
+    td.versioned_importorskip(engine)
     df = DataFrame(np.random.default_rng(2).standard_normal((1, 1)))
     styler = df.style.map(lambda x: css)
 
@@ -142,7 +142,7 @@ def test_styler_to_excel_basic(engine, css, attrs, expected):
             df.to_excel(writer, sheet_name="dataframe")
             styler.to_excel(writer, sheet_name="styled")
 
-        openpyxl = pytest.importorskip("openpyxl")  # test loading only with openpyxl
+        openpyxl = td.versioned_importorskip("openpyxl")  # test loading only with openpyxl
         with contextlib.closing(openpyxl.load_workbook(path)) as wb:
             # test unstyled data cell does not have expected styles
             # test styled cell has expected styles
@@ -164,7 +164,7 @@ def test_styler_to_excel_basic(engine, css, attrs, expected):
 )
 @pytest.mark.parametrize("css, attrs, expected", shared_style_params)
 def test_styler_to_excel_basic_indexes(engine, css, attrs, expected):
-    pytest.importorskip(engine)
+    td.versioned_importorskip(engine)
     df = DataFrame(np.random.default_rng(2).standard_normal((1, 1)))
 
     styler = df.style
@@ -181,7 +181,7 @@ def test_styler_to_excel_basic_indexes(engine, css, attrs, expected):
             null_styler.to_excel(writer, sheet_name="null_styled")
             styler.to_excel(writer, sheet_name="styled")
 
-        openpyxl = pytest.importorskip("openpyxl")  # test loading only with openpyxl
+        openpyxl = td.versioned_importorskip("openpyxl")  # test loading only with openpyxl
         with contextlib.closing(openpyxl.load_workbook(path)) as wb:
             # test null styled index cells does not have expected styles
             # test styled cell has expected styles
@@ -233,7 +233,7 @@ def test_styler_to_excel_border_style(engine, border_style):
     attrs = ["border", "left", "style"]
     expected = border_style
 
-    pytest.importorskip(engine)
+    td.versioned_importorskip(engine)
     df = DataFrame(np.random.default_rng(2).standard_normal((1, 1)))
     styler = df.style.map(lambda x: css)
 
@@ -242,7 +242,7 @@ def test_styler_to_excel_border_style(engine, border_style):
             df.to_excel(writer, sheet_name="dataframe")
             styler.to_excel(writer, sheet_name="styled")
 
-        openpyxl = pytest.importorskip("openpyxl")  # test loading only with openpyxl
+        openpyxl = td.versioned_importorskip("openpyxl")  # test loading only with openpyxl
         with contextlib.closing(openpyxl.load_workbook(path)) as wb:
             # test unstyled data cell does not have expected styles
             # test styled cell has expected styles
@@ -259,7 +259,7 @@ def test_styler_to_excel_border_style(engine, border_style):
 
 
 def test_styler_custom_converter():
-    openpyxl = pytest.importorskip("openpyxl")
+    openpyxl = td.versioned_importorskip("openpyxl")
 
     def custom_converter(css):
         return {"font": {"color": {"rgb": "111222"}}}
index 066393d91eeadcdc08873f4ffeedda0f689337fe..60941e2754b15fba1616d862e4b72b07f882a793 100644 (file)
@@ -3,6 +3,7 @@ import io
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas.compat import is_platform_windows
 
 import pandas as pd
@@ -11,7 +12,7 @@ import pandas._testing as tm
 from pandas.io.excel import ExcelFile
 from pandas.io.excel._base import inspect_excel_format
 
-xlrd = pytest.importorskip("xlrd")
+xlrd = td.versioned_importorskip("xlrd")
 
 if is_platform_windows():
     pytestmark = pytest.mark.single_cpu
index 529367761fc025e3e5d02bea85741c82f64c97ca..8402a7c8b8204349496e7f66ec051289f96bb84f 100644 (file)
@@ -2,6 +2,7 @@ import contextlib
 
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas.compat import is_platform_windows
 
 from pandas import DataFrame
@@ -9,7 +10,7 @@ import pandas._testing as tm
 
 from pandas.io.excel import ExcelWriter
 
-xlsxwriter = pytest.importorskip("xlsxwriter")
+xlsxwriter = td.versioned_importorskip("xlsxwriter")
 
 if is_platform_windows():
     pytestmark = pytest.mark.single_cpu
@@ -23,7 +24,7 @@ def ext():
 def test_column_format(ext):
     # Test that column formats are applied to cells. Test for issue #9167.
     # Applicable to xlsxwriter only.
-    openpyxl = pytest.importorskip("openpyxl")
+    openpyxl = td.versioned_importorskip("openpyxl")
 
     with tm.ensure_clean(ext) as path:
         frame = DataFrame({"A": [123456, 123456], "B": [123456, 123456]})
index d28c7c566d851f16f81cdc04f22e04ca8bde2c71..5da035b6361e120a624f47d8207bb15ff0122007 100644 (file)
@@ -3,13 +3,14 @@ import io
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas import (
     NA,
     DataFrame,
     read_csv,
 )
 
-pytest.importorskip("jinja2")
+td.versioned_importorskip("jinja2")
 
 
 def bar_grad(a=None, b=None, c=None, d=None):
@@ -347,7 +348,7 @@ def test_styler_bar_with_NA_values():
 
 
 def test_style_bar_with_pyarrow_NA_values():
-    pytest.importorskip("pyarrow")
+    td.versioned_importorskip("pyarrow")
     data = """name,age,test1,test2,teacher
         Adam,15,95.0,80,Ashby
         Bob,16,81.0,82,Ashby
index d52e3a37e7693dadce34f73fc03a0790c7a0b4d3..a742f06f06878017b4ba514f36b9e750be41eec4 100644 (file)
@@ -1,6 +1,7 @@
 import pytest
 
-jinja2 = pytest.importorskip("jinja2")
+import pandas.util._test_decorators as td
+jinja2 = td.versioned_importorskip("jinja2")
 
 from pandas import (
     DataFrame,
index 1c84816ead140b95f14df8dbeccc83b317ac239a..3531a47e354e948fe8d0a9480e221264b571d9ff 100644 (file)
@@ -1,6 +1,7 @@
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas import (
     NA,
     DataFrame,
@@ -11,7 +12,7 @@ from pandas import (
     option_context,
 )
 
-pytest.importorskip("jinja2")
+td.versioned_importorskip("jinja2")
 from pandas.io.formats.style import Styler
 from pandas.io.formats.style_render import _str_escape
 
index 3d59719010ee03cc53373a1c96f5f8c5611d7681..b659146a5769679e1c53b4ff8f33816ae68a3bfa 100644 (file)
@@ -1,13 +1,14 @@
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas import (
     NA,
     DataFrame,
     IndexSlice,
 )
 
-pytest.importorskip("jinja2")
+td.versioned_importorskip("jinja2")
 
 from pandas.io.formats.style import Styler
 
index 2c5220da960f1645f6559585ef1dbafcf074bcd4..2f03a579cb0fbc7618024fd45802237424edf3a7 100644 (file)
@@ -6,13 +6,14 @@ from textwrap import (
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas import (
     DataFrame,
     MultiIndex,
     option_context,
 )
 
-jinja2 = pytest.importorskip("jinja2")
+jinja2 = td.versioned_importorskip("jinja2")
 from pandas.io.formats.style import Styler
 
 
index fb7a77f1ddb27db66a847fc1a1d87d14d95822aa..30f03065ee4499f9448c074c679c3b182256fd3b 100644 (file)
@@ -3,14 +3,15 @@ import gc
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas import (
     DataFrame,
     IndexSlice,
     Series,
 )
 
-pytest.importorskip("matplotlib")
-pytest.importorskip("jinja2")
+td.versioned_importorskip("matplotlib")
+td.versioned_importorskip("jinja2")
 
 import matplotlib as mpl
 
@@ -23,9 +24,9 @@ def mpl_cleanup():
     # 1) Resets units registry
     # 2) Resets rc_context
     # 3) Closes all figures
-    mpl = pytest.importorskip("matplotlib")
-    mpl_units = pytest.importorskip("matplotlib.units")
-    plt = pytest.importorskip("matplotlib.pyplot")
+    mpl = td.versioned_importorskip("matplotlib")
+    mpl_units = td.versioned_importorskip("matplotlib.units")
+    plt = td.versioned_importorskip("matplotlib.pyplot")
     orig_units_registry = mpl_units.registry.copy()
     with mpl.rc_context():
         mpl.use("template")
index e4d31fe21f2c9cf3454a67f8c7443382f7f1c0ef..278fbf7b37cabf8b289ee52823f87cd4e77ed3c4 100644 (file)
@@ -2,12 +2,13 @@ from textwrap import dedent
 
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas import (
     DataFrame,
     IndexSlice,
 )
 
-pytest.importorskip("jinja2")
+td.versioned_importorskip("jinja2")
 
 from pandas.io.formats.style import Styler
 
index 3e231e37d1dd67c9c03d4d7f42bdaa1303df6d7a..118b926a4856ec9e9ba512d95bcb441eda0e0b2d 100644 (file)
@@ -6,6 +6,7 @@ from textwrap import dedent
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas import (
     DataFrame,
     IndexSlice,
@@ -16,7 +17,7 @@ from pandas import (
 import pandas._testing as tm
 import pandas.util._test_decorators as td
 
-jinja2 = pytest.importorskip("jinja2")
+jinja2 = td.versioned_importorskip("jinja2")
 from pandas.io.formats.style import (  # isort:skip
     Styler,
 )
index 7f1443c3ee66be040f668f546682924207cfd31e..e804cfb6b0b3d38d6f79b7e245baad1c60942caa 100644 (file)
@@ -3,6 +3,7 @@ from textwrap import dedent
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas import (
     DataFrame,
     MultiIndex,
@@ -10,7 +11,7 @@ from pandas import (
     option_context,
 )
 
-pytest.importorskip("jinja2")
+td.versioned_importorskip("jinja2")
 from pandas.io.formats.style import Styler
 from pandas.io.formats.style_render import (
     _parse_latex_cell_styles,
index e6f84cc9e9cd89ae63ff7a04bff70bade5874d85..cfe92eba0817dbe88b3d558c664a0f00d6545050 100644 (file)
@@ -2,12 +2,13 @@ from textwrap import dedent
 
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas import (
     DataFrame,
     Series,
 )
 
-pytest.importorskip("jinja2")
+td.versioned_importorskip("jinja2")
 from pandas.io.formats.style import Styler
 
 
index c49a0e05c67002ab0b6eebd1ffd3bda554622f4d..9d21067c20a2036d56500a34a48aca4262ccd0d9 100644 (file)
@@ -1,9 +1,10 @@
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas import DataFrame
 
-pytest.importorskip("jinja2")
+td.versioned_importorskip("jinja2")
 from pandas.io.formats.style import Styler
 
 
index 535ef76cb12f4c5e46f0397c16d1f7806557b075..17c54ea71ca528ca62d3f52a0a45011037c27b82 100644 (file)
@@ -11,6 +11,7 @@ from shutil import get_terminal_size
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas._config import using_string_dtype
 
 import pandas as pd
@@ -2264,7 +2265,7 @@ def test_filepath_or_buffer_arg(
 ):
     df = DataFrame([data])
     if method in ["to_latex"]:  # uses styler implementation
-        pytest.importorskip("jinja2")
+        td.versioned_importorskip("jinja2")
 
     if filepath_or_buffer_id not in ["string", "pathlike"] and encoding is not None:
         with pytest.raises(
@@ -2283,7 +2284,7 @@ def test_filepath_or_buffer_arg(
 @pytest.mark.parametrize("method", ["to_string", "to_html", "to_latex"])
 def test_filepath_or_buffer_bad_arg_raises(float_frame, method):
     if method in ["to_latex"]:  # uses styler implementation
-        pytest.importorskip("jinja2")
+        td.versioned_importorskip("jinja2")
     msg = "buf is not a file name and it has no write method"
     with pytest.raises(TypeError, match=msg):
         getattr(float_frame, method)(buf=object())
index 927a9f4961f6ff7ae51f74aceb0cb36dc6754c21..583d11b6633cd9ea3ff6f285a73bca157e60d162 100644 (file)
@@ -6,6 +6,7 @@ import string
 
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas.errors import CSSWarning
 
 import pandas._testing as tm
@@ -336,7 +337,7 @@ def tests_css_named_colors_valid():
 
 
 def test_css_named_colors_from_mpl_present():
-    mpl_colors = pytest.importorskip("matplotlib.colors")
+    mpl_colors = td.versioned_importorskip("matplotlib.colors")
 
     pd_colors = CSSToExcelConverter.NAMED_COLORS
     for name, color in mpl_colors.CSS4_COLORS.items():
index a4feaa8d867bdb8d18ebf409791be3ee1a8d9f1a..90cfa8d72e78eab89c9f11dfbc628d8af3b65b01 100644 (file)
@@ -3,6 +3,7 @@ from textwrap import dedent
 
 import pytest
 
+import pandas.util._test_decorators as td
 import pandas as pd
 from pandas import (
     DataFrame,
@@ -10,7 +11,7 @@ from pandas import (
 )
 import pandas._testing as tm
 
-pytest.importorskip("jinja2")
+td.versioned_importorskip("jinja2")
 
 
 def _dedent(string):
index 85eca834ff0d43ca30eb4043ed9f97fd3807899b..af9195738500e8044746231325430f0b948eba43 100644 (file)
@@ -5,10 +5,11 @@ from io import (
 
 import pytest
 
+import pandas.util._test_decorators as td
 import pandas as pd
 import pandas._testing as tm
 
-pytest.importorskip("tabulate")
+td.versioned_importorskip("tabulate")
 
 
 def test_simple():
index 164e51426260305d3bf6d37037b601eaaaf8d5bc..17a69d4beb232b333936860e63446ad903c44161 100644 (file)
@@ -10,6 +10,7 @@ from textwrap import dedent
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas._config import using_string_dtype
 
 from pandas import (
@@ -748,7 +749,7 @@ class TestDataFrameToString:
 
     def test_to_string_string_dtype(self):
         # GH#50099
-        pytest.importorskip("pyarrow")
+        td.versioned_importorskip("pyarrow")
         df = DataFrame(
             {"x": ["foo", "bar", "baz"], "y": ["a", "b", "c"], "z": [1, 2, 3]}
         )
index 10f1e7df648f0d0aada247e6cb9182e8f4409189..5bbf62ab13c36bb5e519e4a4b1ec9088928185a5 100644 (file)
@@ -2050,7 +2050,7 @@ class TestPandasContainer:
             )
 
         if dtype_backend == "pyarrow":
-            pa = pytest.importorskip("pyarrow")
+            pa = td.versioned_importorskip("pyarrow")
             string_dtype = pd.ArrowDtype(pa.string())
         else:
             string_dtype = pd.StringDtype(string_storage)
@@ -2069,7 +2069,7 @@ class TestPandasContainer:
         )
 
         if dtype_backend == "pyarrow":
-            pa = pytest.importorskip("pyarrow")
+            pa = td.versioned_importorskip("pyarrow")
             from pandas.arrays import ArrowExtensionArray
 
             expected = DataFrame(
@@ -2089,7 +2089,7 @@ class TestPandasContainer:
     @pytest.mark.parametrize("orient", ["split", "records", "index"])
     def test_read_json_nullable_series(self, string_storage, dtype_backend, orient):
         # GH#50750
-        pa = pytest.importorskip("pyarrow")
+        pa = td.versioned_importorskip("pyarrow")
         ser = Series([1, np.nan, 3], dtype="Int64")
 
         out = ser.to_json(orient=orient)
index d96ccb4b94cc2c567c8d7e59cad3227017f9200d..5663f238a96b8fc348489209190fe225cb5ab39d 100644 (file)
@@ -5,6 +5,7 @@ from pathlib import Path
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 import pandas as pd
 from pandas import (
     DataFrame,
@@ -28,7 +29,7 @@ def lines_json_df():
 @pytest.fixture(params=["ujson", "pyarrow"])
 def engine(request):
     if request.param == "pyarrow":
-        pytest.importorskip("pyarrow.json")
+        td.versioned_importorskip("pyarrow.json")
     return request.param
 
 
index 90f77a7024235f3458f96ba4e2938b7c28f966b4..556eefd9db13e9750ad897d80ed0538cd3ec99ca 100644 (file)
@@ -4,6 +4,7 @@ import os
 
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas.compat import HAS_PYARROW
 from pandas.compat._optional import VERSIONS
 
@@ -144,7 +145,7 @@ def all_parsers(request):
     """
     parser = request.param()
     if parser.engine == "pyarrow":
-        pytest.importorskip("pyarrow", VERSIONS["pyarrow"])
+        td.versioned_importorskip("pyarrow", VERSIONS["pyarrow"])
         # Try finding a way to disable threads all together
         # for more stable CI runs
         import pyarrow
index d28c43c45647a53bea2877760868ae1fa11264d6..4979a04997fa8ee831e1f1f23b1046a7e50e0e8e 100644 (file)
@@ -8,6 +8,7 @@ from io import StringIO
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas.errors import ParserWarning
 
 import pandas as pd
@@ -492,7 +493,7 @@ def test_dtype_backend_ea_dtype_specified(all_parsers):
 
 def test_dtype_backend_pyarrow(all_parsers, request):
     # GH#36712
-    pa = pytest.importorskip("pyarrow")
+    pa = td.versioned_importorskip("pyarrow")
     parser = all_parsers
 
     data = """a,b,c,d,e,f,g,h,i,j
index 1bae2317a2fc602a436d17e80bc8d4bfdcd7fe5f..8c828460ae8eb213c988b43d1fbf7d702eec0160 100644 (file)
@@ -1,6 +1,7 @@
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas.errors import DtypeWarning
 
 import pandas._testing as tm
@@ -11,7 +12,7 @@ from pandas.io.parsers.c_parser_wrapper import _concatenate_chunks
 
 def test_concatenate_chunks_pyarrow():
     # GH#51876
-    pa = pytest.importorskip("pyarrow")
+    pa = td.versioned_importorskip("pyarrow")
     chunks = [
         {0: ArrowExtensionArray(pa.array([1.5, 2.5]))},
         {0: ArrowExtensionArray(pa.array([1, 2]))},
@@ -23,7 +24,7 @@ def test_concatenate_chunks_pyarrow():
 
 def test_concatenate_chunks_pyarrow_strings():
     # GH#51876
-    pa = pytest.importorskip("pyarrow")
+    pa = td.versioned_importorskip("pyarrow")
     chunks = [
         {0: ArrowExtensionArray(pa.array([1.5, 2.5]))},
         {0: ArrowExtensionArray(pa.array(["a", "b"]))},
index 85921e4252f52fe765665f0618b8d00e95cd235b..80cc34c1c3ccf0e37375f619339ad8eac6b42c65 100644 (file)
@@ -15,6 +15,7 @@ except ImportError:
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 import pandas as pd
 from pandas import DataFrame
 import pandas._testing as tm
@@ -35,7 +36,7 @@ def test_multi_thread_string_io_read_csv(all_parsers, request):
     # see gh-11786
     parser = all_parsers
     if parser.engine == "pyarrow":
-        pa = pytest.importorskip("pyarrow")
+        pa = td.versioned_importorskip("pyarrow")
         if Version(pa.__version__) < Version("16.0"):
             request.applymarker(
                 pytest.mark.xfail(reason="# ValueError: Found non-unique column index")
index 9351387dfc3379e6b90756a3a771ec5d46ec4065..d064e836b6b01b989703ee893d5e967ba83ca35b 100644 (file)
@@ -80,7 +80,7 @@ class TestS3:
     def test_parse_public_s3_bucket(self, s3_public_bucket_with_data, tips_df, s3so):
         # more of an integration test due to the not-public contents portion
         # can probably mock this though.
-        pytest.importorskip("s3fs")
+        td.versioned_importorskip("s3fs")
         for ext, comp in [("", None), (".gz", "gzip"), (".bz2", "bz2")]:
             df = read_csv(
                 f"s3://{s3_public_bucket_with_data.name}/tips.csv" + ext,
@@ -93,7 +93,7 @@ class TestS3:
 
     def test_parse_private_s3_bucket(self, s3_private_bucket_with_data, tips_df, s3so):
         # Read public file from bucket with not-public contents
-        pytest.importorskip("s3fs")
+        td.versioned_importorskip("s3fs")
         df = read_csv(
             f"s3://{s3_private_bucket_with_data.name}/tips.csv", storage_options=s3so
         )
@@ -258,7 +258,7 @@ class TestS3:
     def test_write_s3_parquet_fails(self, tips_df, s3so):
         # GH 27679
         # Attempting to write to an invalid S3 path should raise
-        pytest.importorskip("pyarrow")
+        td.versioned_importorskip("pyarrow")
         import botocore
 
         # GH 34087
@@ -318,7 +318,7 @@ class TestS3:
         self, s3_public_bucket_with_data, feather_file, s3so
     ):
         # GH 29055
-        pytest.importorskip("pyarrow")
+        td.versioned_importorskip("pyarrow")
         expected = read_feather(feather_file)
         res = read_feather(
             f"s3://{s3_public_bucket_with_data.name}/simple_dataset.feather",
index 5f2ddf7de9c6d2339ec7115e30c773ca947e4d21..f24c453a9f91d3a77ce5812d9a19070931daaed4 100644 (file)
@@ -17,6 +17,7 @@ from typing import TYPE_CHECKING
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas.errors import (
     ParserError,
     ParserWarning,
@@ -167,7 +168,7 @@ def test_decompression_regex_sep(python_parser_only, csv1, compression, klass):
     data = data.replace(b",", b"::")
     expected = parser.read_csv(csv1)
 
-    module = pytest.importorskip(compression)
+    module = td.versioned_importorskip(compression)
     klass = getattr(module, klass)
 
     with tm.ensure_clean() as path:
index d8fe168341ff121996d0c69dddd044918bcf081c..4ffbc0a945d48d18140222c882bdffe2bae90df4 100644 (file)
@@ -14,6 +14,7 @@ from pathlib import Path
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas.errors import EmptyDataError
 
 import pandas as pd
@@ -971,7 +972,7 @@ def test_dtype_backend(string_storage, dtype_backend):
         result = read_fwf(StringIO(data), dtype_backend=dtype_backend)
 
     if dtype_backend == "pyarrow":
-        pa = pytest.importorskip("pyarrow")
+        pa = td.versioned_importorskip("pyarrow")
         string_dtype = pd.ArrowDtype(pa.string())
     else:
         string_dtype = pd.StringDtype(string_storage)
@@ -990,7 +991,7 @@ def test_dtype_backend(string_storage, dtype_backend):
         }
     )
     if dtype_backend == "pyarrow":
-        pa = pytest.importorskip("pyarrow")
+        pa = td.versioned_importorskip("pyarrow")
         from pandas.arrays import ArrowExtensionArray
 
         expected = DataFrame(
index bc4c4c2e24e9caf8d4ac118b5053fe03d97aafb0..5014a2546b4ee1c0235a98fc25d34bec0375b5fc 100644 (file)
@@ -1,6 +1,7 @@
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas._libs.parsers import (
     _maybe_upcast,
     na_values,
@@ -87,7 +88,7 @@ def test_maybe_upcaste_all_nan():
 @pytest.mark.parametrize("val", [na_values[np.object_], "c"])
 def test_maybe_upcast_object(val, string_storage):
     # GH#36712
-    pa = pytest.importorskip("pyarrow")
+    pa = td.versioned_importorskip("pyarrow")
 
     with pd.option_context("mode.string_storage", string_storage):
         arr = np.array(["a", "b", val], dtype=np.object_)
index 62582b212eb387c94b095ca54029f971dc54e777..825ab1b9dac41a8bc30e6e3e14d8d931ba14b86e 100644 (file)
@@ -5,9 +5,10 @@ import tempfile
 
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas.io.pytables import HDFStore
 
-tables = pytest.importorskip("tables")
+tables = td.versioned_importorskip("tables")
 # set these parameters so we don't have file sharing
 tables.parameters.MAX_NUMEXPR_THREADS = 1
 tables.parameters.MAX_BLOSC_THREADS = 1
index 40bfd54484346be2d9f8b2f29c2029d2d2b8072a..467a9ad3b24343938f2a0cd08a597233f642f37b 100644 (file)
@@ -29,7 +29,7 @@ is_crashing_arch=bool((platform.uname()[4].startswith('arm') or platform.uname()
 
 pytestmark = [pytest.mark.single_cpu]
 
-tables = pytest.importorskip("tables")
+tables = td.versioned_importorskip("tables")
 
 
 @pytest.mark.filterwarnings("ignore::tables.NaturalNameWarning")
index b07fb3ddd3ac829f5b90d6fd7226926aeed284e6..6bf427ea3ff7d0dc4a90bd7b89f455ddfedc5677 100644 (file)
@@ -1,9 +1,10 @@
 import pytest
 
+import pandas.util._test_decorators as td
 import pandas as pd
 import pandas._testing as tm
 
-tables = pytest.importorskip("tables")
+tables = td.versioned_importorskip("tables")
 
 
 @pytest.fixture
index 040708c9cedd07782bd0485c410de81f2fae2f2a..b6b8dc3e2bf2303fcf5dbcb1b5d3235cf77b2949 100644 (file)
@@ -574,7 +574,7 @@ def test_round_trip_equals(tmp_path, setup_path):
 
 def test_infer_string_columns(tmp_path, setup_path):
     # GH#
-    pytest.importorskip("pyarrow")
+    td.versioned_importorskip("pyarrow")
     path = tmp_path / setup_path
     with pd.option_context("future.infer_string", True):
         df = DataFrame(1, columns=list("ABCD"), index=list(range(10))).set_index(
index 24ab5e3c5d308a7d7bd541edcac7c0472c4e7f26..dc0b7f3c70ab215c6c1c9e31a60f3d19554592eb 100644 (file)
@@ -7,6 +7,7 @@ import time
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 import pandas as pd
 from pandas import (
     DataFrame,
@@ -37,7 +38,7 @@ is_crashing_arch=bool((platform.uname()[4].startswith('arm') or platform.uname()
 
 pytestmark = [pytest.mark.single_cpu]
 
-tables = pytest.importorskip("tables")
+tables = td.versioned_importorskip("tables")
 
 
 def test_context(setup_path):
index 03622faa2b5a8f65d709c23cab23fd3680084cb4..d9ed6f246226aa8f80b4bc7bfcca47251d8c26fd 100644 (file)
@@ -1,6 +1,7 @@
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas import (
     DataFrame,
     Series,
@@ -12,7 +13,7 @@ from pandas.io.pytables import (
     read_hdf,
 )
 
-pytest.importorskip("tables")
+td.versioned_importorskip("tables")
 
 
 class TestHDFStoreSubclass:
index a16c63e8d3d65f1354fdb4c32c0599fec644bd01..d0fa31fb973159dd9ea1e43915a12950bd205b63 100644 (file)
@@ -3,6 +3,7 @@ from textwrap import dedent
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas.errors import (
     PyperclipException,
     PyperclipWindowsException,
@@ -349,7 +350,7 @@ class TestClipboard:
     ):
         # GH#50502
         if dtype_backend == "pyarrow":
-            pa = pytest.importorskip("pyarrow")
+            pa = td.versioned_importorskip("pyarrow")
             if engine == "c" and string_storage == "pyarrow":
                 # TODO avoid this exception?
                 string_dtype = pd.ArrowDtype(pa.large_string())
index 70c662cd0a87ef8f43f5aa34f6e4fee7026872f0..86e3eaed017e603496789663c2932244747411d3 100644 (file)
@@ -101,7 +101,7 @@ bar2,12,13,14,15
 
     def test_stringify_file_and_path_like(self):
         # GH 38125: do not stringify file objects that are also path-like
-        fsspec = pytest.importorskip("fsspec")
+        fsspec = td.versioned_importorskip("fsspec")
         with tm.ensure_clean() as path:
             with fsspec.open(f"file://{path}", mode="wb") as fsspec_obj:
                 assert fsspec_obj == icom.stringify_path(fsspec_obj)
@@ -154,7 +154,7 @@ Look,a snake,🐍"""
 
     # Test that pyarrow can handle a file opened with get_handle
     def test_get_handle_pyarrow_compat(self):
-        pa_csv = pytest.importorskip("pyarrow.csv")
+        pa_csv = td.versioned_importorskip("pyarrow.csv")
 
         # Test latin1, ucs-2, and ucs-4 chars
         data = """a,b,c
@@ -199,7 +199,7 @@ Look,a snake,🐍"""
         ],
     )
     def test_read_non_existent(self, reader, module, error_class, fn_ext):
-        pytest.importorskip(module)
+        td.versioned_importorskip(module)
 
         path = os.path.join(HERE, "data", "does_not_exist." + fn_ext)
         msg1 = rf"File (b')?.+does_not_exist\.{fn_ext}'? does not exist"
@@ -237,7 +237,7 @@ Look,a snake,🐍"""
     )
     # NOTE: Missing parent directory for pd.DataFrame.to_hdf is handled by PyTables
     def test_write_missing_parent_directory(self, method, module, error_class, fn_ext):
-        pytest.importorskip(module)
+        td.versioned_importorskip(module)
 
         dummy_frame = pd.DataFrame({"a": [1, 2, 3], "b": [2, 3, 4], "c": [3, 4, 5]})
 
@@ -267,7 +267,7 @@ Look,a snake,🐍"""
     def test_read_expands_user_home_dir(
         self, reader, module, error_class, fn_ext, monkeypatch
     ):
-        pytest.importorskip(module)
+        td.versioned_importorskip(module)
 
         path = os.path.join("~", "does_not_exist." + fn_ext)
         monkeypatch.setattr(icom, "_expand_user", lambda x: os.path.join("foo", x))
@@ -326,7 +326,7 @@ Look,a snake,🐍"""
         ],
     )
     def test_read_fspath_all(self, reader, module, path, datapath):
-        pytest.importorskip(module)
+        td.versioned_importorskip(module)
         path = datapath(*path)
 
         mypath = CustomFSPath(path)
@@ -354,13 +354,13 @@ Look,a snake,🐍"""
     )
     def test_write_fspath_all(self, writer_name, writer_kwargs, module):
         if writer_name in ["to_latex"]:  # uses Styler implementation
-            pytest.importorskip("jinja2")
+            td.versioned_importorskip("jinja2")
         p1 = tm.ensure_clean("string")
         p2 = tm.ensure_clean("fspath")
         df = pd.DataFrame({"A": [1, 2]})
 
         with p1 as string, p2 as fspath:
-            pytest.importorskip(module)
+            td.versioned_importorskip(module)
             mypath = CustomFSPath(fspath)
             writer = getattr(df, writer_name)
 
@@ -382,7 +382,7 @@ Look,a snake,🐍"""
         # Same test as write_fspath_all, except HDF5 files aren't
         # necessarily byte-for-byte identical for a given dataframe, so we'll
         # have to read and compare equality
-        pytest.importorskip("tables")
+        td.versioned_importorskip("tables")
 
         df = pd.DataFrame({"A": [1, 2]})
         p1 = tm.ensure_clean("string")
index 0ab23e3b51a03dbfa1a82151703a996ec7594de7..35b0f87ba1d8ea9523aad8fbc02d90fdb7b08285 100644 (file)
@@ -2,6 +2,7 @@
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas.compat.pyarrow import (
     pa_version_under18p0,
     pa_version_under19p0,
@@ -17,7 +18,7 @@ pytestmark = pytest.mark.filterwarnings(
 )
 
 
-pa = pytest.importorskip("pyarrow")
+pa = td.versioned_importorskip("pyarrow")
 
 
 @pytest.mark.single_cpu
@@ -192,7 +193,7 @@ class TestFeather:
                 result = read_feather(path, dtype_backend=dtype_backend)
 
         if dtype_backend == "pyarrow":
-            pa = pytest.importorskip("pyarrow")
+            pa = td.versioned_importorskip("pyarrow")
             if using_infer_string:
                 string_dtype = pd.ArrowDtype(pa.large_string())
             else:
index dde85f9f8409d9eb7a5efe2ca61939102dd8f887..b66577e6a5691f821959f58f5902e99cc9b53345 100644 (file)
@@ -27,7 +27,7 @@ pytestmark = pytest.mark.filterwarnings(
 
 @pytest.fixture
 def fsspectest():
-    pytest.importorskip("fsspec")
+    td.versioned_importorskip("fsspec")
     from fsspec import register_implementation
     from fsspec.implementations.memory import MemoryFileSystem
     from fsspec.registry import _registry as registry
@@ -61,7 +61,7 @@ def df1():
 
 @pytest.fixture
 def cleared_fs():
-    fsspec = pytest.importorskip("fsspec")
+    fsspec = td.versioned_importorskip("fsspec")
 
     memfs = fsspec.filesystem("memory")
     yield memfs
@@ -101,7 +101,7 @@ def test_to_csv(cleared_fs, df1):
 
 
 def test_to_excel(cleared_fs, df1):
-    pytest.importorskip("openpyxl")
+    td.versioned_importorskip("openpyxl")
     ext = "xlsx"
     path = f"memory://test/test.{ext}"
     df1.to_excel(path, index=True)
@@ -113,7 +113,7 @@ def test_to_excel(cleared_fs, df1):
 
 @pytest.mark.parametrize("binary_mode", [False, True])
 def test_to_csv_fsspec_object(cleared_fs, binary_mode, df1):
-    fsspec = pytest.importorskip("fsspec")
+    fsspec = td.versioned_importorskip("fsspec")
 
     path = "memory://test/test.csv"
     mode = "wb" if binary_mode else "w"
@@ -155,7 +155,7 @@ def test_read_table_options(fsspectest):
 
 
 def test_excel_options(fsspectest):
-    pytest.importorskip("openpyxl")
+    td.versioned_importorskip("openpyxl")
     extension = "xlsx"
 
     df = DataFrame({"a": [0]})
@@ -170,7 +170,7 @@ def test_excel_options(fsspectest):
 
 def test_to_parquet_new_file(cleared_fs, df1):
     """Regression test for writing to a not-yet-existent GCS Parquet file."""
-    pytest.importorskip("fastparquet")
+    td.versioned_importorskip("fastparquet")
 
     df1.to_parquet(
         "memory://test/test.csv", index=True, engine="fastparquet", compression=None
@@ -179,7 +179,7 @@ def test_to_parquet_new_file(cleared_fs, df1):
 
 def test_arrowparquet_options(fsspectest):
     """Regression test for writing to a not-yet-existent GCS Parquet file."""
-    pytest.importorskip("pyarrow")
+    td.versioned_importorskip("pyarrow")
     df = DataFrame({"a": [0]})
     df.to_parquet(
         "testmem://test/test.csv",
@@ -199,7 +199,7 @@ def test_arrowparquet_options(fsspectest):
 @td.skip_array_manager_not_yet_implemented  # TODO(ArrayManager) fastparquet
 def test_fastparquet_options(fsspectest):
     """Regression test for writing to a not-yet-existent GCS Parquet file."""
-    pytest.importorskip("fastparquet")
+    td.versioned_importorskip("fastparquet")
 
     df = DataFrame({"a": [0]})
     df.to_parquet(
@@ -219,7 +219,7 @@ def test_fastparquet_options(fsspectest):
 
 @pytest.mark.single_cpu
 def test_from_s3_csv(s3_public_bucket_with_data, tips_file, s3so):
-    pytest.importorskip("s3fs")
+    td.versioned_importorskip("s3fs")
     tm.assert_equal(
         read_csv(
             f"s3://{s3_public_bucket_with_data.name}/tips.csv", storage_options=s3so
@@ -244,7 +244,7 @@ def test_from_s3_csv(s3_public_bucket_with_data, tips_file, s3so):
 @pytest.mark.single_cpu
 @pytest.mark.parametrize("protocol", ["s3", "s3a", "s3n"])
 def test_s3_protocols(s3_public_bucket_with_data, tips_file, protocol, s3so):
-    pytest.importorskip("s3fs")
+    td.versioned_importorskip("s3fs")
     tm.assert_equal(
         read_csv(
             f"{protocol}://{s3_public_bucket_with_data.name}/tips.csv",
@@ -258,8 +258,8 @@ def test_s3_protocols(s3_public_bucket_with_data, tips_file, protocol, s3so):
 @pytest.mark.single_cpu
 @td.skip_array_manager_not_yet_implemented  # TODO(ArrayManager) fastparquet
 def test_s3_parquet(s3_public_bucket, s3so, df1):
-    pytest.importorskip("fastparquet")
-    pytest.importorskip("s3fs")
+    td.versioned_importorskip("fastparquet")
+    td.versioned_importorskip("s3fs")
 
     fn = f"s3://{s3_public_bucket.name}/test.parquet"
     df1.to_parquet(
@@ -277,7 +277,7 @@ def test_not_present_exception():
 
 
 def test_feather_options(fsspectest):
-    pytest.importorskip("pyarrow")
+    td.versioned_importorskip("pyarrow")
     df = DataFrame({"a": [0]})
     df.to_feather("testmem://mockfile", storage_options={"test": "feather_write"})
     assert fsspectest.test[0] == "feather_write"
@@ -324,7 +324,7 @@ def test_stata_options(fsspectest):
 
 
 def test_markdown_options(fsspectest):
-    pytest.importorskip("tabulate")
+    td.versioned_importorskip("tabulate")
     df = DataFrame({"a": [0]})
     df.to_markdown("testmem://mockfile", storage_options={"test": "md_write"})
     assert fsspectest.test[0] == "md_write"
@@ -332,7 +332,7 @@ def test_markdown_options(fsspectest):
 
 
 def test_non_fsspec_options():
-    pytest.importorskip("pyarrow")
+    td.versioned_importorskip("pyarrow")
     with pytest.raises(ValueError, match="storage_options"):
         read_csv("localfile", storage_options={"a": True})
     with pytest.raises(ValueError, match="storage_options"):
index 9fc0f6eb4776661b542e637ddda7992baa248192..fdf90dd12d6f0db883e3273eb6040b2c4e83a5c5 100644 (file)
@@ -29,8 +29,8 @@ pytestmark = pytest.mark.filterwarnings(
 @pytest.fixture
 def gcs_buffer():
     """Emulate GCS using a binary buffer."""
-    pytest.importorskip("gcsfs")
-    fsspec = pytest.importorskip("fsspec")
+    td.versioned_importorskip("gcsfs")
+    fsspec = td.versioned_importorskip("fsspec")
 
     gcs_buffer = BytesIO()
     gcs_buffer.close = lambda: True
@@ -83,8 +83,8 @@ def test_to_read_gcs(gcs_buffer, format, monkeypatch, capsys, request):
         df1.to_json(path)
         df2 = read_json(path, convert_dates=["dt"])
     elif format == "parquet":
-        pytest.importorskip("pyarrow")
-        pa_fs = pytest.importorskip("pyarrow.fs")
+        td.versioned_importorskip("pyarrow")
+        pa_fs = td.versioned_importorskip("pyarrow.fs")
 
         class MockFileSystem(pa_fs.FileSystem):
             @staticmethod
@@ -107,7 +107,7 @@ def test_to_read_gcs(gcs_buffer, format, monkeypatch, capsys, request):
         captured = capsys.readouterr()
         assert captured.out == "Using pyarrow filesystem\nUsing pyarrow filesystem\n"
     elif format == "markdown":
-        pytest.importorskip("tabulate")
+        td.versioned_importorskip("tabulate")
         df1.to_markdown(path)
         df2 = df1
 
@@ -196,8 +196,8 @@ def test_to_csv_compression_encoding_gcs(
 
 def test_to_parquet_gcs_new_file(monkeypatch, tmpdir):
     """Regression test for writing to a not-yet-existent GCS Parquet file."""
-    pytest.importorskip("fastparquet")
-    pytest.importorskip("gcsfs")
+    td.versioned_importorskip("fastparquet")
+    td.versioned_importorskip("gcsfs")
 
     from fsspec import AbstractFileSystem
 
index b12098d4904c1a1d5ced85045c16c142e4d8e4af..d5e8f1065eec7ae38f12a4857d1f6fd249607524 100644 (file)
@@ -67,8 +67,8 @@ def assert_framelist_equal(list1, list2, *args, **kwargs):
 
 
 def test_bs4_version_fails(monkeypatch, datapath):
-    bs4 = pytest.importorskip("bs4")
-    pytest.importorskip("html5lib")
+    bs4 = td.versioned_importorskip("bs4")
+    td.versioned_importorskip("html5lib")
 
     monkeypatch.setattr(bs4, "__version__", "4.2")
     with pytest.raises(ImportError, match="Pandas requires version"):
@@ -85,9 +85,9 @@ def test_invalid_flavor():
 
 
 def test_same_ordering(datapath):
-    pytest.importorskip("bs4")
-    pytest.importorskip("lxml")
-    pytest.importorskip("html5lib")
+    td.versioned_importorskip("bs4")
+    td.versioned_importorskip("lxml")
+    td.versioned_importorskip("html5lib")
 
     filename = datapath("io", "data", "html", "valid_markup.html")
     dfs_lxml = read_html(filename, index_col=0, flavor=["lxml"])
@@ -181,7 +181,7 @@ class TestReadHtml:
             result = flavor_read_html(StringIO(out), dtype_backend=dtype_backend)[0]
 
         if dtype_backend == "pyarrow":
-            pa = pytest.importorskip("pyarrow")
+            pa = td.versioned_importorskip("pyarrow")
             string_dtype = pd.ArrowDtype(pa.string())
         else:
             string_dtype = pd.StringDtype(string_storage)
index 9918435cae15b000171efad0242c652a31859505..6c30c842e4cad83bad87433d980a32618c87e803 100644 (file)
@@ -164,7 +164,7 @@ def test_to_parquet_to_disk_with_storage_options(engine):
         "Auth": "other_custom",
     }
 
-    pytest.importorskip(engine)
+    td.versioned_importorskip(engine)
 
     true_df = pd.DataFrame({"column_name": ["column_value"]})
     msg = (
index 4c4d7461e4ac5a2249a3ae23de038de0e3cfe9a1..b5bc30436ceffbaa784e42831468ae1bf2ac6766 100644 (file)
@@ -8,12 +8,13 @@ import pathlib
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 import pandas as pd
 from pandas import read_orc
 import pandas._testing as tm
 from pandas.core.arrays import StringArray
 
-pytest.importorskip("pyarrow.orc")
+td.versioned_importorskip("pyarrow.orc")
 
 import pyarrow as pa
 
@@ -249,7 +250,7 @@ def test_orc_reader_snappy_compressed(dirpath):
 def test_orc_roundtrip_file(dirpath):
     # GH44554
     # PyArrow gained ORC write support with the current argument order
-    pytest.importorskip("pyarrow")
+    td.versioned_importorskip("pyarrow")
 
     data = {
         "boolean1": np.array([False, True], dtype="bool"),
@@ -274,7 +275,7 @@ def test_orc_roundtrip_file(dirpath):
 def test_orc_roundtrip_bytesio():
     # GH44554
     # PyArrow gained ORC write support with the current argument order
-    pytest.importorskip("pyarrow")
+    td.versioned_importorskip("pyarrow")
 
     data = {
         "boolean1": np.array([False, True], dtype="bool"),
@@ -298,7 +299,7 @@ def test_orc_roundtrip_bytesio():
 def test_orc_writer_dtypes_not_supported(orc_writer_dtypes_not_supported):
     # GH44554
     # PyArrow gained ORC write support with the current argument order
-    pytest.importorskip("pyarrow")
+    td.versioned_importorskip("pyarrow")
 
     msg = "The dtype of one or more columns is not supported yet."
     with pytest.raises(NotImplementedError, match=msg):
@@ -306,7 +307,7 @@ def test_orc_writer_dtypes_not_supported(orc_writer_dtypes_not_supported):
 
 
 def test_orc_dtype_backend_pyarrow(using_infer_string):
-    pytest.importorskip("pyarrow")
+    td.versioned_importorskip("pyarrow")
     df = pd.DataFrame(
         {
             "string": list("abc"),
@@ -349,7 +350,7 @@ def test_orc_dtype_backend_pyarrow(using_infer_string):
 
 def test_orc_dtype_backend_numpy_nullable():
     # GH#50503
-    pytest.importorskip("pyarrow")
+    td.versioned_importorskip("pyarrow")
     df = pd.DataFrame(
         {
             "string": list("abc"),
index 45aed8df6d416697e20558653806025fbf6f3b84..8bbb4ae928983724a108c3fd5553aa76e4a9a6dd 100644 (file)
@@ -8,6 +8,7 @@ import pathlib
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas._config import (
     using_copy_on_write,
     using_string_dtype,
@@ -619,7 +620,7 @@ class TestBasic(Base):
             check_round_trip(df, engine)
 
     def test_dtype_backend(self, engine, request):
-        pq = pytest.importorskip("pyarrow.parquet")
+        pq = td.versioned_importorskip("pyarrow.parquet")
 
         if engine == "fastparquet":
             # We are manually disabling fastparquet's
@@ -704,7 +705,7 @@ class TestBasic(Base):
     @pytest.mark.single_cpu
     def test_parquet_read_from_url(self, httpserver, datapath, df_compat, engine):
         if engine != "auto":
-            pytest.importorskip(engine)
+            td.versioned_importorskip(engine)
         with open(datapath("io", "data", "parquet", "simple.parquet"), mode="rb") as f:
             httpserver.serve_content(content=f.read())
             df = read_parquet(httpserver.url, engine=engine)
@@ -820,7 +821,7 @@ class TestParquetPyArrow(Base):
 
     @pytest.mark.single_cpu
     def test_s3_roundtrip_explicit_fs(self, df_compat, s3_public_bucket, pa, s3so):
-        s3fs = pytest.importorskip("s3fs")
+        s3fs = td.versioned_importorskip("s3fs")
         s3 = s3fs.S3FileSystem(**s3so)
         kw = {"filesystem": s3}
         check_round_trip(
@@ -854,7 +855,7 @@ class TestParquetPyArrow(Base):
     def test_s3_roundtrip_for_dir(
         self, df_compat, s3_public_bucket, pa, partition_col, s3so
     ):
-        pytest.importorskip("s3fs")
+        td.versioned_importorskip("s3fs")
         # GH #26388
         expected_df = df_compat.copy()
 
@@ -883,7 +884,7 @@ class TestParquetPyArrow(Base):
         )
 
     def test_read_file_like_obj_support(self, df_compat, using_infer_string):
-        pytest.importorskip("pyarrow")
+        td.versioned_importorskip("pyarrow")
         buffer = BytesIO()
         df_compat.to_parquet(buffer)
         df_from_buf = read_parquet(buffer)
@@ -892,7 +893,7 @@ class TestParquetPyArrow(Base):
         tm.assert_frame_equal(df_compat, df_from_buf)
 
     def test_expand_user(self, df_compat, monkeypatch):
-        pytest.importorskip("pyarrow")
+        td.versioned_importorskip("pyarrow")
         monkeypatch.setenv("HOME", "TestingUser")
         monkeypatch.setenv("USERPROFILE", "TestingUser")
         with pytest.raises(OSError, match=r".*TestingUser.*"):
@@ -947,7 +948,7 @@ class TestParquetPyArrow(Base):
     def test_additional_extension_arrays(self, pa, using_infer_string):
         # test additional ExtensionArrays that are supported through the
         # __arrow_array__ protocol
-        pytest.importorskip("pyarrow")
+        td.versioned_importorskip("pyarrow")
         df = pd.DataFrame(
             {
                 "a": pd.Series([1, 2, 3], dtype="Int64"),
@@ -965,7 +966,7 @@ class TestParquetPyArrow(Base):
 
     def test_pyarrow_backed_string_array(self, pa, string_storage, using_infer_string):
         # test ArrowStringArray supported through the __arrow_array__ protocol
-        pytest.importorskip("pyarrow")
+        td.versioned_importorskip("pyarrow")
         df = pd.DataFrame({"a": pd.Series(["a", None, "c"], dtype="string[pyarrow]")})
         with pd.option_context("string_storage", string_storage):
             if using_infer_string:
@@ -981,7 +982,7 @@ class TestParquetPyArrow(Base):
     def test_additional_extension_types(self, pa):
         # test additional ExtensionArrays that are supported through the
         # __arrow_array__ protocol + by defining a custom ExtensionType
-        pytest.importorskip("pyarrow")
+        td.versioned_importorskip("pyarrow")
         df = pd.DataFrame(
             {
                 "c": pd.IntervalIndex.from_tuples([(0, 1), (1, 2), (3, 4)]),
@@ -1003,7 +1004,7 @@ class TestParquetPyArrow(Base):
         check_round_trip(df, pa, write_kwargs={"version": ver})
 
     def test_timezone_aware_index(self, pa, timezone_aware_date_list):
-        pytest.importorskip("pyarrow", "11.0.0")
+        td.versioned_importorskip("pyarrow", "11.0.0")
 
         idx = 5 * [timezone_aware_date_list]
         df = pd.DataFrame(index=idx, data={"index_as_col": idx})
@@ -1037,7 +1038,7 @@ class TestParquetPyArrow(Base):
 
     def test_filter_row_groups(self, pa):
         # https://github.com/pandas-dev/pandas/issues/26551
-        pytest.importorskip("pyarrow")
+        td.versioned_importorskip("pyarrow")
         df = pd.DataFrame({"a": list(range(3))})
         with tm.ensure_clean() as path:
             df.to_parquet(path, engine=pa)
@@ -1424,7 +1425,7 @@ class TestParquetFastParquet(Base):
         tm.assert_frame_equal(result, df)
 
     def test_filesystem_notimplemented(self):
-        pytest.importorskip("fastparquet")
+        td.versioned_importorskip("fastparquet")
         df = pd.DataFrame(data={"A": [0, 1], "B": [1, 0]})
         with tm.ensure_clean() as path:
             with pytest.raises(
@@ -1440,7 +1441,7 @@ class TestParquetFastParquet(Base):
                 read_parquet(path, engine="fastparquet", filesystem="foo")
 
     def test_invalid_filesystem(self):
-        pytest.importorskip("pyarrow")
+        td.versioned_importorskip("pyarrow")
         df = pd.DataFrame(data={"A": [0, 1], "B": [1, 0]})
         with tm.ensure_clean() as path:
             with pytest.raises(
@@ -1456,7 +1457,7 @@ class TestParquetFastParquet(Base):
                 read_parquet(path, engine="pyarrow", filesystem="foo")
 
     def test_unsupported_pa_filesystem_storage_options(self):
-        pa_fs = pytest.importorskip("pyarrow.fs")
+        pa_fs = td.versioned_importorskip("pyarrow.fs")
         df = pd.DataFrame(data={"A": [0, 1], "B": [1, 0]})
         with tm.ensure_clean() as path:
             with pytest.raises(
index 64ff3c6abc09301d93a040e1ac72845537461591..ad9f2f9d55714c27024bcd52d643ee44eda07403 100644 (file)
@@ -505,7 +505,7 @@ def test_pickle_generalurl_read(monkeypatch, mockurl):
 
 
 def test_pickle_fsspec_roundtrip():
-    pytest.importorskip("fsspec")
+    td.versioned_importorskip("fsspec")
     with tm.ensure_clean():
         mockurl = "memory://mockfile"
         df = DataFrame(
index 79473895b662da6af68fbe29a60eb05f134a54df..4e8113f17f864f8fec4258632c602bd1e83cc839 100644 (file)
@@ -2,13 +2,14 @@ from io import BytesIO
 
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas import read_csv
 
 
 def test_streaming_s3_objects():
     # GH17135
     # botocore gained iteration support in 1.10.47, can now be used in read_*
-    pytest.importorskip("botocore", minversion="1.10.47")
+    td.versioned_importorskip("botocore", min_version="1.10.47")
     from botocore.response import StreamingBody
 
     data = [b"foo,bar,baz\n1,2,3\n4,5,6\n", b"just,the,header\n"]
@@ -20,7 +21,7 @@ def test_streaming_s3_objects():
 @pytest.mark.single_cpu
 def test_read_without_creds_from_pub_bucket(s3_public_bucket_with_data, s3so):
     # GH 34626
-    pytest.importorskip("s3fs")
+    td.versioned_importorskip("s3fs")
     result = read_csv(
         f"s3://{s3_public_bucket_with_data.name}/tips.csv",
         nrows=3,
@@ -33,7 +34,7 @@ def test_read_without_creds_from_pub_bucket(s3_public_bucket_with_data, s3so):
 def test_read_with_creds_from_pub_bucket(s3_public_bucket_with_data, s3so):
     # Ensure we can read from a public bucket with credentials
     # GH 34626
-    pytest.importorskip("s3fs")
+    td.versioned_importorskip("s3fs")
     df = read_csv(
         f"s3://{s3_public_bucket_with_data.name}/tips.csv",
         nrows=5,
index 82613b4e807258d1df6134c1447fe4401379f147..33229b8cb294c1dd0f9351312452abd9724efce3 100644 (file)
@@ -4,11 +4,12 @@ from pathlib import Path
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 import pandas as pd
 import pandas._testing as tm
 from pandas.util.version import Version
 
-pyreadstat = pytest.importorskip("pyreadstat")
+pyreadstat = td.versioned_importorskip("pyreadstat")
 
 
 # TODO(CoW) - detection of chained assignment in cython
@@ -101,7 +102,7 @@ def test_spss_umlauts_dtype_backend(datapath, dtype_backend):
     expected = pd.DataFrame({"var1": [1.0, 2.0, 1.0, 3.0]}, dtype="Int64")
 
     if dtype_backend == "pyarrow":
-        pa = pytest.importorskip("pyarrow")
+        pa = td.versioned_importorskip("pyarrow")
 
         from pandas.arrays import ArrowExtensionArray
 
index 89adf18545815bc9198584a3fc442c58635874e9..c133b51d716753706fae88a093e01b6afa1ea98e 100644 (file)
@@ -602,8 +602,8 @@ def drop_view(
 
 @pytest.fixture
 def mysql_pymysql_engine():
-    sqlalchemy = pytest.importorskip("sqlalchemy")
-    pymysql = pytest.importorskip("pymysql")
+    sqlalchemy = td.versioned_importorskip("sqlalchemy")
+    pymysql = td.versioned_importorskip("pymysql")
     engine = sqlalchemy.create_engine(
         "mysql+pymysql://root@localhost:3306/pandas",
         connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS},
@@ -650,8 +650,8 @@ def mysql_pymysql_conn_types(mysql_pymysql_engine_types):
 
 @pytest.fixture
 def postgresql_psycopg2_engine():
-    sqlalchemy = pytest.importorskip("sqlalchemy")
-    pytest.importorskip("psycopg2")
+    sqlalchemy = td.versioned_importorskip("sqlalchemy")
+    td.versioned_importorskip("psycopg2")
     engine = sqlalchemy.create_engine(
         "postgresql+psycopg2://postgres:postgres@localhost:5432/pandas",
         poolclass=sqlalchemy.pool.NullPool,
@@ -685,8 +685,8 @@ def postgresql_psycopg2_conn(postgresql_psycopg2_engine):
 
 @pytest.fixture
 def postgresql_adbc_conn():
-    pytest.importorskip("pyarrow")
-    pytest.importorskip("adbc_driver_postgresql")
+    td.versioned_importorskip("pyarrow")
+    td.versioned_importorskip("adbc_driver_postgresql")
     from adbc_driver_postgresql import dbapi
 
     uri = "postgresql://postgres:postgres@localhost:5432/pandas"
@@ -749,14 +749,14 @@ def postgresql_psycopg2_conn_types(postgresql_psycopg2_engine_types):
 
 @pytest.fixture
 def sqlite_str():
-    pytest.importorskip("sqlalchemy")
+    td.versioned_importorskip("sqlalchemy")
     with tm.ensure_clean() as name:
         yield f"sqlite:///{name}"
 
 
 @pytest.fixture
 def sqlite_engine(sqlite_str):
-    sqlalchemy = pytest.importorskip("sqlalchemy")
+    sqlalchemy = td.versioned_importorskip("sqlalchemy")
     engine = sqlalchemy.create_engine(sqlite_str, poolclass=sqlalchemy.pool.NullPool)
     yield engine
     for view in get_all_views(engine):
@@ -774,7 +774,7 @@ def sqlite_conn(sqlite_engine):
 
 @pytest.fixture
 def sqlite_str_iris(sqlite_str, iris_path):
-    sqlalchemy = pytest.importorskip("sqlalchemy")
+    sqlalchemy = td.versioned_importorskip("sqlalchemy")
     engine = sqlalchemy.create_engine(sqlite_str)
     create_and_load_iris(engine, iris_path)
     create_and_load_iris_view(engine)
@@ -797,7 +797,7 @@ def sqlite_conn_iris(sqlite_engine_iris):
 
 @pytest.fixture
 def sqlite_str_types(sqlite_str, types_data):
-    sqlalchemy = pytest.importorskip("sqlalchemy")
+    sqlalchemy = td.versioned_importorskip("sqlalchemy")
     engine = sqlalchemy.create_engine(sqlite_str)
     create_and_load_types(engine, types_data, "sqlite")
     engine.dispose()
@@ -818,8 +818,8 @@ def sqlite_conn_types(sqlite_engine_types):
 
 @pytest.fixture
 def sqlite_adbc_conn():
-    pytest.importorskip("pyarrow")
-    pytest.importorskip("adbc_driver_sqlite")
+    td.versioned_importorskip("pyarrow")
+    td.versioned_importorskip("adbc_driver_sqlite")
     from adbc_driver_sqlite import dbapi
 
     with tm.ensure_clean() as name:
@@ -1004,7 +1004,7 @@ def test_dataframe_to_sql_empty(conn, test_frame1, request):
 @pytest.mark.parametrize("conn", all_connectable)
 def test_dataframe_to_sql_arrow_dtypes(conn, request):
     # GH 52046
-    pytest.importorskip("pyarrow")
+    td.versioned_importorskip("pyarrow")
     df = DataFrame(
         {
             "int": pd.array([1], dtype="int8[pyarrow]"),
@@ -1038,7 +1038,7 @@ def test_dataframe_to_sql_arrow_dtypes(conn, request):
 @pytest.mark.parametrize("conn", all_connectable)
 def test_dataframe_to_sql_arrow_dtypes_missing(conn, request, nulls_fixture):
     # GH 52046
-    pytest.importorskip("pyarrow")
+    td.versioned_importorskip("pyarrow")
     df = DataFrame(
         {
             "datetime": pd.array(
@@ -2323,7 +2323,7 @@ def test_api_escaped_table_name(conn, request):
 def test_api_read_sql_duplicate_columns(conn, request):
     # GH#53117
     if "adbc" in conn:
-        pa = pytest.importorskip("pyarrow")
+        pa = td.versioned_importorskip("pyarrow")
         if not (
             Version(pa.__version__) >= Version("16.0")
             and conn in ["sqlite_adbc_conn", "postgresql_adbc_conn"]
@@ -2518,7 +2518,7 @@ def test_sqlalchemy_integer_overload_mapping(conn, request, integer):
 
 @pytest.mark.parametrize("conn", all_connectable)
 def test_database_uri_string(conn, request, test_frame1):
-    pytest.importorskip("sqlalchemy")
+    td.versioned_importorskip("sqlalchemy")
     conn = request.getfixturevalue(conn)
     # Test read_sql and .to_sql method with a database URI (GH10654)
     # db_uri = 'sqlite:///:memory:' # raises
@@ -2540,7 +2540,7 @@ def test_database_uri_string(conn, request, test_frame1):
 @td.skip_if_installed("pg8000")
 @pytest.mark.parametrize("conn", all_connectable)
 def test_pg8000_sqlalchemy_passthrough_error(conn, request):
-    pytest.importorskip("sqlalchemy")
+    td.versioned_importorskip("sqlalchemy")
     conn = request.getfixturevalue(conn)
     # using driver that will not be installed on CI to trigger error
     # in sqlalchemy.create_engine -> test passing of this error to user
@@ -3417,7 +3417,7 @@ def test_to_sql_with_negative_npinf(conn, request, input):
         # The input {"foo": [-np.inf], "infe0": ["bar"]} does not raise any error
         # for pymysql version >= 0.10
         # TODO(GH#36465): remove this version check after GH 36465 is fixed
-        pymysql = pytest.importorskip("pymysql")
+        pymysql = td.versioned_importorskip("pymysql")
 
         if Version(pymysql.__version__) < Version("1.0.3") and "infe0" in df.columns:
             mark = pytest.mark.xfail(reason="GH 36465")
@@ -3532,7 +3532,7 @@ def test_options_auto(conn, request, test_frame1):
 
 
 def test_options_get_engine():
-    pytest.importorskip("sqlalchemy")
+    td.versioned_importorskip("sqlalchemy")
     assert isinstance(get_engine("sqlalchemy"), SQLAlchemyEngine)
 
     with pd.option_context("io.sql.engine", "sqlalchemy"):
@@ -3680,7 +3680,7 @@ def dtype_backend_expected():
     def func(string_storage, dtype_backend, conn_name) -> DataFrame:
         string_dtype: pd.StringDtype | pd.ArrowDtype
         if dtype_backend == "pyarrow":
-            pa = pytest.importorskip("pyarrow")
+            pa = td.versioned_importorskip("pyarrow")
             string_dtype = pd.ArrowDtype(pa.string())
         else:
             string_dtype = pd.StringDtype(string_storage)
@@ -3698,7 +3698,7 @@ def dtype_backend_expected():
             }
         )
         if dtype_backend == "pyarrow":
-            pa = pytest.importorskip("pyarrow")
+            pa = td.versioned_importorskip("pyarrow")
 
             from pandas.arrays import ArrowExtensionArray
 
index 8c1c7bd9d77623349bf6735e6e3d9a21bf7e763a..8e0634aee09b78708b14cd70a79b9ee523b845b0 100644 (file)
@@ -2062,11 +2062,11 @@ def test_compression(compression, version, use_dict, infer, compression_to_exten
             with bz2.open(path, "rb") as comp:
                 fp = io.BytesIO(comp.read())
         elif compression == "zstd":
-            zstd = pytest.importorskip("zstandard")
+            zstd = td.versioned_importorskip("zstandard")
             with zstd.open(path, "rb") as comp:
                 fp = io.BytesIO(comp.read())
         elif compression == "xz":
-            lzma = pytest.importorskip("lzma")
+            lzma = td.versioned_importorskip("lzma")
             with lzma.open(path, "rb") as comp:
                 fp = io.BytesIO(comp.read())
         elif compression is None:
index 37251a58b0c119ef1da15c259e9e77a456b86ac9..69a7d85ea6b4cbbda2f7fb06d12d1134c56c11ff 100644 (file)
@@ -867,7 +867,7 @@ def test_encoding_option_str(xml_baby_names, parser):
 
 
 def test_correct_encoding_file(xml_baby_names):
-    pytest.importorskip("lxml")
+    td.versioned_importorskip("lxml")
     df_file = read_xml(xml_baby_names, encoding="ISO-8859-1", parser="lxml")
 
     with tm.ensure_clean("test.xml") as path:
@@ -876,7 +876,7 @@ def test_correct_encoding_file(xml_baby_names):
 
 @pytest.mark.parametrize("encoding", ["UTF-8", "UTF-16", "ISO-8859-1"])
 def test_wrong_encoding_option_lxml(xml_baby_names, parser, encoding):
-    pytest.importorskip("lxml")
+    td.versioned_importorskip("lxml")
     df_file = read_xml(xml_baby_names, encoding="ISO-8859-1", parser="lxml")
 
     with tm.ensure_clean("test.xml") as path:
@@ -892,7 +892,7 @@ def test_misspelled_encoding(parser, geom_df):
 
 
 def test_xml_declaration_pretty_print(geom_df):
-    pytest.importorskip("lxml")
+    td.versioned_importorskip("lxml")
     expected = """\
 <data>
   <row>
@@ -1005,7 +1005,7 @@ xsl_expected = """\
 
 
 def test_stylesheet_file_like(xsl_row_field_output, mode, geom_df):
-    pytest.importorskip("lxml")
+    td.versioned_importorskip("lxml")
     with open(
         xsl_row_field_output, mode, encoding="utf-8" if mode == "r" else None
     ) as f:
@@ -1015,7 +1015,7 @@ def test_stylesheet_file_like(xsl_row_field_output, mode, geom_df):
 def test_stylesheet_io(xsl_row_field_output, mode, geom_df):
     # note: By default the bodies of untyped functions are not checked,
     # consider using --check-untyped-defs
-    pytest.importorskip("lxml")
+    td.versioned_importorskip("lxml")
     xsl_obj: BytesIO | StringIO  # type: ignore[annotation-unchecked]
 
     with open(
@@ -1032,7 +1032,7 @@ def test_stylesheet_io(xsl_row_field_output, mode, geom_df):
 
 
 def test_stylesheet_buffered_reader(xsl_row_field_output, mode, geom_df):
-    pytest.importorskip("lxml")
+    td.versioned_importorskip("lxml")
     with open(
         xsl_row_field_output, mode, encoding="utf-8" if mode == "r" else None
     ) as f:
@@ -1044,7 +1044,7 @@ def test_stylesheet_buffered_reader(xsl_row_field_output, mode, geom_df):
 
 
 def test_stylesheet_wrong_path(geom_df):
-    lxml_etree = pytest.importorskip("lxml.etree")
+    lxml_etree = td.versioned_importorskip("lxml.etree")
 
     xsl = os.path.join("data", "xml", "row_field_output.xslt")
 
@@ -1057,7 +1057,7 @@ def test_stylesheet_wrong_path(geom_df):
 
 @pytest.mark.parametrize("val", ["", b""])
 def test_empty_string_stylesheet(val, geom_df):
-    lxml_etree = pytest.importorskip("lxml.etree")
+    lxml_etree = td.versioned_importorskip("lxml.etree")
 
     msg = "|".join(
         [
@@ -1073,7 +1073,7 @@ def test_empty_string_stylesheet(val, geom_df):
 
 
 def test_incorrect_xsl_syntax(geom_df):
-    lxml_etree = pytest.importorskip("lxml.etree")
+    lxml_etree = td.versioned_importorskip("lxml.etree")
 
     xsl = """\
 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
@@ -1103,7 +1103,7 @@ def test_incorrect_xsl_syntax(geom_df):
 
 
 def test_incorrect_xsl_eval(geom_df):
-    lxml_etree = pytest.importorskip("lxml.etree")
+    lxml_etree = td.versioned_importorskip("lxml.etree")
 
     xsl = """\
 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
@@ -1131,7 +1131,7 @@ def test_incorrect_xsl_eval(geom_df):
 
 
 def test_incorrect_xsl_apply(geom_df):
-    lxml_etree = pytest.importorskip("lxml.etree")
+    lxml_etree = td.versioned_importorskip("lxml.etree")
 
     xsl = """\
 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
@@ -1169,7 +1169,7 @@ def test_stylesheet_with_etree(geom_df):
 
 
 def test_style_to_csv(geom_df):
-    pytest.importorskip("lxml")
+    td.versioned_importorskip("lxml")
     xsl = """\
 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output method="text" indent="yes" />
@@ -1198,7 +1198,7 @@ def test_style_to_csv(geom_df):
 
 
 def test_style_to_string(geom_df):
-    pytest.importorskip("lxml")
+    td.versioned_importorskip("lxml")
     xsl = """\
 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output method="text" indent="yes" />
@@ -1232,7 +1232,7 @@ def test_style_to_string(geom_df):
 
 
 def test_style_to_json(geom_df):
-    pytest.importorskip("lxml")
+    td.versioned_importorskip("lxml")
     xsl = """\
 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output method="text" indent="yes" />
@@ -1363,8 +1363,8 @@ def test_unsuported_compression(parser, geom_df):
 
 @pytest.mark.single_cpu
 def test_s3_permission_output(parser, s3_public_bucket, geom_df):
-    s3fs = pytest.importorskip("s3fs")
-    pytest.importorskip("lxml")
+    s3fs = td.versioned_importorskip("s3fs")
+    td.versioned_importorskip("lxml")
 
     with tm.external_error_raised((PermissionError, FileNotFoundError)):
         fs = s3fs.S3FileSystem(anon=True)
index ab800dbed8fd06b057e1f2606097a841a61cc0b2..58bec3964c3eee740b370bcecd99cfd5869d1b27 100644 (file)
@@ -244,7 +244,7 @@ df_kml = DataFrame(
 
 def test_literal_xml_deprecation():
     # GH 53809
-    pytest.importorskip("lxml")
+    td.versioned_importorskip("lxml")
     msg = (
         "Passing literal xml to 'read_xml' is deprecated and "
         "will be removed in a future version. To read from a "
@@ -284,7 +284,7 @@ def read_xml_iterparse_comp(comp_path, compression_only, **kwargs):
 
 
 def test_parser_consistency_file(xml_books):
-    pytest.importorskip("lxml")
+    td.versioned_importorskip("lxml")
     df_file_lxml = read_xml(xml_books, parser="lxml")
     df_file_etree = read_xml(xml_books, parser="etree")
 
@@ -457,7 +457,7 @@ def test_file_handle_close(xml_books, parser):
 
 @pytest.mark.parametrize("val", ["", b""])
 def test_empty_string_lxml(val):
-    lxml_etree = pytest.importorskip("lxml.etree")
+    lxml_etree = td.versioned_importorskip("lxml.etree")
 
     msg = "|".join(
         [
@@ -500,7 +500,7 @@ def test_wrong_file_path(parser, datapath):
 @pytest.mark.network
 @pytest.mark.single_cpu
 def test_url(httpserver, xml_file):
-    pytest.importorskip("lxml")
+    td.versioned_importorskip("lxml")
     with open(xml_file, encoding="utf-8") as f:
         httpserver.serve_content(content=f.read())
         df_url = read_xml(httpserver.url, xpath=".//book[count(*)=4]")
@@ -582,7 +582,7 @@ def test_whitespace(parser):
 
 
 def test_empty_xpath_lxml(xml_books):
-    pytest.importorskip("lxml")
+    td.versioned_importorskip("lxml")
     with pytest.raises(ValueError, match=("xpath does not return any nodes")):
         read_xml(xml_books, xpath=".//python", parser="lxml")
 
@@ -595,7 +595,7 @@ def test_bad_xpath_etree(xml_books):
 
 
 def test_bad_xpath_lxml(xml_books):
-    lxml_etree = pytest.importorskip("lxml.etree")
+    lxml_etree = td.versioned_importorskip("lxml.etree")
 
     with pytest.raises(lxml_etree.XPathEvalError, match=("Invalid expression")):
         read_xml(xml_books, xpath=".//[book]", parser="lxml")
@@ -654,7 +654,7 @@ def test_prefix_namespace(parser):
 
 
 def test_consistency_default_namespace():
-    pytest.importorskip("lxml")
+    td.versioned_importorskip("lxml")
     df_lxml = read_xml(
         StringIO(xml_default_nmsp),
         xpath=".//ns:row",
@@ -673,7 +673,7 @@ def test_consistency_default_namespace():
 
 
 def test_consistency_prefix_namespace():
-    pytest.importorskip("lxml")
+    td.versioned_importorskip("lxml")
     df_lxml = read_xml(
         StringIO(xml_prefix_nmsp),
         xpath=".//doc:row",
@@ -705,7 +705,7 @@ def test_missing_prefix_definition_etree(kml_cta_rail_lines):
 
 
 def test_missing_prefix_definition_lxml(kml_cta_rail_lines):
-    lxml_etree = pytest.importorskip("lxml.etree")
+    lxml_etree = td.versioned_importorskip("lxml.etree")
 
     with pytest.raises(lxml_etree.XPathEvalError, match=("Undefined namespace prefix")):
         read_xml(kml_cta_rail_lines, xpath=".//kml:Placemark", parser="lxml")
@@ -713,7 +713,7 @@ def test_missing_prefix_definition_lxml(kml_cta_rail_lines):
 
 @pytest.mark.parametrize("key", ["", None])
 def test_none_namespace_prefix(key):
-    pytest.importorskip("lxml")
+    td.versioned_importorskip("lxml")
     with pytest.raises(
         TypeError, match=("empty namespace prefix is not supported in XPath")
     ):
@@ -826,7 +826,7 @@ def test_empty_elems_only(parser):
 
 
 def test_attribute_centric_xml():
-    pytest.importorskip("lxml")
+    td.versioned_importorskip("lxml")
     xml = """\
 <?xml version="1.0" encoding="UTF-8"?>
 <TrainSchedule>
@@ -1056,7 +1056,7 @@ def test_ascii_encoding(xml_baby_names, parser):
 
 
 def test_parser_consistency_with_encoding(xml_baby_names):
-    pytest.importorskip("lxml")
+    td.versioned_importorskip("lxml")
     df_xpath_lxml = read_xml(xml_baby_names, parser="lxml", encoding="ISO-8859-1")
     df_xpath_etree = read_xml(xml_baby_names, parser="etree", encoding="iso-8859-1")
 
@@ -1079,7 +1079,7 @@ def test_parser_consistency_with_encoding(xml_baby_names):
 
 
 def test_wrong_encoding_for_lxml():
-    pytest.importorskip("lxml")
+    td.versioned_importorskip("lxml")
     # GH#45133
     data = """<data>
   <row>
@@ -1126,7 +1126,7 @@ def test_wrong_parser(xml_books):
 
 
 def test_stylesheet_file(kml_cta_rail_lines, xsl_flatten_doc):
-    pytest.importorskip("lxml")
+    td.versioned_importorskip("lxml")
     df_style = read_xml(
         kml_cta_rail_lines,
         xpath=".//k:Placemark",
@@ -1153,7 +1153,7 @@ def test_stylesheet_file(kml_cta_rail_lines, xsl_flatten_doc):
 
 
 def test_stylesheet_file_like(kml_cta_rail_lines, xsl_flatten_doc, mode):
-    pytest.importorskip("lxml")
+    td.versioned_importorskip("lxml")
     with open(xsl_flatten_doc, mode, encoding="utf-8" if mode == "r" else None) as f:
         df_style = read_xml(
             kml_cta_rail_lines,
@@ -1168,7 +1168,7 @@ def test_stylesheet_file_like(kml_cta_rail_lines, xsl_flatten_doc, mode):
 def test_stylesheet_io(kml_cta_rail_lines, xsl_flatten_doc, mode):
     # note: By default the bodies of untyped functions are not checked,
     # consider using --check-untyped-defs
-    pytest.importorskip("lxml")
+    td.versioned_importorskip("lxml")
     xsl_obj: BytesIO | StringIO  # type: ignore[annotation-unchecked]
 
     with open(xsl_flatten_doc, mode, encoding="utf-8" if mode == "r" else None) as f:
@@ -1188,7 +1188,7 @@ def test_stylesheet_io(kml_cta_rail_lines, xsl_flatten_doc, mode):
 
 
 def test_stylesheet_buffered_reader(kml_cta_rail_lines, xsl_flatten_doc, mode):
-    pytest.importorskip("lxml")
+    td.versioned_importorskip("lxml")
     with open(xsl_flatten_doc, mode, encoding="utf-8" if mode == "r" else None) as f:
         xsl_obj = f.read()
 
@@ -1203,7 +1203,7 @@ def test_stylesheet_buffered_reader(kml_cta_rail_lines, xsl_flatten_doc, mode):
 
 
 def test_style_charset():
-    pytest.importorskip("lxml")
+    td.versioned_importorskip("lxml")
     xml = "<中文標籤><row><c1>1</c1><c2>2</c2></row></中文標籤>"
 
     xsl = """\
@@ -1232,7 +1232,7 @@ def test_style_charset():
 
 
 def test_not_stylesheet(kml_cta_rail_lines, xml_books):
-    lxml_etree = pytest.importorskip("lxml.etree")
+    lxml_etree = td.versioned_importorskip("lxml.etree")
 
     with pytest.raises(
         lxml_etree.XSLTParseError, match=("document is not a stylesheet")
@@ -1241,7 +1241,7 @@ def test_not_stylesheet(kml_cta_rail_lines, xml_books):
 
 
 def test_incorrect_xsl_syntax(kml_cta_rail_lines):
-    lxml_etree = pytest.importorskip("lxml.etree")
+    lxml_etree = td.versioned_importorskip("lxml.etree")
 
     xsl = """\
 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
@@ -1270,7 +1270,7 @@ def test_incorrect_xsl_syntax(kml_cta_rail_lines):
 
 
 def test_incorrect_xsl_eval(kml_cta_rail_lines):
-    lxml_etree = pytest.importorskip("lxml.etree")
+    lxml_etree = td.versioned_importorskip("lxml.etree")
 
     xsl = """\
 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
@@ -1297,7 +1297,7 @@ def test_incorrect_xsl_eval(kml_cta_rail_lines):
 
 
 def test_incorrect_xsl_apply(kml_cta_rail_lines):
-    lxml_etree = pytest.importorskip("lxml.etree")
+    lxml_etree = td.versioned_importorskip("lxml.etree")
 
     xsl = """\
 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
@@ -1316,7 +1316,7 @@ def test_incorrect_xsl_apply(kml_cta_rail_lines):
 
 
 def test_wrong_stylesheet(kml_cta_rail_lines, xml_data_path):
-    xml_etree = pytest.importorskip("lxml.etree")
+    xml_etree = td.versioned_importorskip("lxml.etree")
 
     xsl = xml_data_path / "flatten.xsl"
 
@@ -1330,7 +1330,7 @@ def test_wrong_stylesheet(kml_cta_rail_lines, xml_data_path):
 def test_stylesheet_file_close(kml_cta_rail_lines, xsl_flatten_doc, mode):
     # note: By default the bodies of untyped functions are not checked,
     # consider using --check-untyped-defs
-    pytest.importorskip("lxml")
+    td.versioned_importorskip("lxml")
     xsl_obj: BytesIO | StringIO  # type: ignore[annotation-unchecked]
 
     with open(xsl_flatten_doc, mode, encoding="utf-8" if mode == "r" else None) as f:
@@ -1345,7 +1345,7 @@ def test_stylesheet_file_close(kml_cta_rail_lines, xsl_flatten_doc, mode):
 
 
 def test_stylesheet_with_etree(kml_cta_rail_lines, xsl_flatten_doc):
-    pytest.importorskip("lxml")
+    td.versioned_importorskip("lxml")
     with pytest.raises(
         ValueError, match=("To use stylesheet, you need lxml installed")
     ):
@@ -1354,7 +1354,7 @@ def test_stylesheet_with_etree(kml_cta_rail_lines, xsl_flatten_doc):
 
 @pytest.mark.parametrize("val", ["", b""])
 def test_empty_stylesheet(val, datapath):
-    pytest.importorskip("lxml")
+    td.versioned_importorskip("lxml")
     msg = (
         "Passing literal xml to 'read_xml' is deprecated and "
         "will be removed in a future version. To read from a "
@@ -1657,7 +1657,7 @@ def test_empty_data(xml_books, parser):
 
 
 def test_online_stylesheet():
-    pytest.importorskip("lxml")
+    td.versioned_importorskip("lxml")
     xml = """\
 <?xml version="1.0" encoding="UTF-8"?>
 <catalog>
@@ -1988,8 +1988,8 @@ def test_unsuported_compression(parser):
 @pytest.mark.network
 @pytest.mark.single_cpu
 def test_s3_parser_consistency(s3_public_bucket_with_data, s3so):
-    pytest.importorskip("s3fs")
-    pytest.importorskip("lxml")
+    td.versioned_importorskip("s3fs")
+    td.versioned_importorskip("lxml")
     s3 = f"s3://{s3_public_bucket_with_data.name}/books.xml"
 
     df_lxml = read_xml(s3, parser="lxml", storage_options=s3so)
@@ -2033,7 +2033,7 @@ def test_read_xml_nullable_dtypes(
         result = read_xml(StringIO(data), parser=parser, dtype_backend=dtype_backend)
 
     if dtype_backend == "pyarrow":
-        pa = pytest.importorskip("pyarrow")
+        pa = td.versioned_importorskip("pyarrow")
         string_dtype = pd.ArrowDtype(pa.string())
     else:
         string_dtype = pd.StringDtype(string_storage)
@@ -2053,7 +2053,7 @@ def test_read_xml_nullable_dtypes(
     )
 
     if dtype_backend == "pyarrow":
-        pa = pytest.importorskip("pyarrow")
+        pa = td.versioned_importorskip("pyarrow")
         from pandas.arrays import ArrowExtensionArray
 
         expected = DataFrame(
index d688bbd47595c2ec6451bd9ddf7c916275013384..174c5d1e95e6fb172c73e34bf90fe1e3f2f04eef 100644 (file)
@@ -3,6 +3,7 @@ import gc
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas import (
     DataFrame,
     to_datetime,
@@ -15,9 +16,9 @@ def mpl_cleanup():
     # 1) Resets units registry
     # 2) Resets rc_context
     # 3) Closes all figures
-    mpl = pytest.importorskip("matplotlib")
-    mpl_units = pytest.importorskip("matplotlib.units")
-    plt = pytest.importorskip("matplotlib.pyplot")
+    mpl = td.versioned_importorskip("matplotlib")
+    mpl_units = td.versioned_importorskip("matplotlib.units")
+    plt = td.versioned_importorskip("matplotlib.pyplot")
     orig_units_registry = mpl_units.registry.copy()
     with mpl.rc_context():
         mpl.use("template")
index 33366b4eabba5b4827b8710fb6edc27f3754d5e7..4db50c2d4d85e486cdd2ed5aa8151916b0892e7c 100644 (file)
@@ -48,8 +48,8 @@ from pandas.util.version import Version
 
 from pandas.io.formats.printing import pprint_thing
 
-mpl = pytest.importorskip("matplotlib")
-plt = pytest.importorskip("matplotlib.pyplot")
+mpl = td.versioned_importorskip("matplotlib")
+plt = td.versioned_importorskip("matplotlib.pyplot")
 
 
 class TestDataFramePlots:
@@ -1144,7 +1144,7 @@ class TestDataFramePlots:
         _check_box_return_type(result, return_type)
 
     def test_kde_df(self):
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         df = DataFrame(np.random.default_rng(2).standard_normal((100, 4)))
         ax = _check_plot_works(df.plot, kind="kde")
         expected = [pprint_thing(c) for c in df.columns]
@@ -1152,13 +1152,13 @@ class TestDataFramePlots:
         _check_ticks_props(ax, xrot=0)
 
     def test_kde_df_rot(self):
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         df = DataFrame(np.random.default_rng(2).standard_normal((10, 4)))
         ax = df.plot(kind="kde", rot=20, fontsize=5)
         _check_ticks_props(ax, xrot=20, xlabelsize=5, ylabelsize=5)
 
     def test_kde_df_subplots(self):
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         df = DataFrame(np.random.default_rng(2).standard_normal((10, 4)))
         axes = _check_plot_works(
             df.plot,
@@ -1169,13 +1169,13 @@ class TestDataFramePlots:
         _check_axes_shape(axes, axes_num=4, layout=(4, 1))
 
     def test_kde_df_logy(self):
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         df = DataFrame(np.random.default_rng(2).standard_normal((10, 4)))
         axes = df.plot(kind="kde", logy=True, subplots=True)
         _check_ax_scales(axes, yaxis="log")
 
     def test_kde_missing_vals(self):
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         df = DataFrame(np.random.default_rng(2).uniform(size=(100, 4)))
         df.loc[0, 0] = np.nan
         _check_plot_works(df.plot, kind="kde")
@@ -1472,14 +1472,14 @@ class TestDataFramePlots:
 
     @pytest.mark.parametrize("kind", plotting.PlotAccessor._common_kinds)
     def test_kind_both_ways(self, kind):
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         df = DataFrame({"x": [1, 2, 3]})
         df.plot(kind=kind)
         getattr(df.plot, kind)()
 
     @pytest.mark.parametrize("kind", ["scatter", "hexbin"])
     def test_kind_both_ways_x_y(self, kind):
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         df = DataFrame({"x": [1, 2, 3]})
         df.plot("x", "x", kind=kind)
         getattr(df.plot, kind)("x", "x")
@@ -2125,7 +2125,7 @@ class TestDataFramePlots:
     @pytest.mark.parametrize("kind", plotting.PlotAccessor._all_kinds)
     def test_memory_leak(self, kind):
         """Check that every plot type gets properly collected."""
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         args = {}
         if kind in ["hexbin", "scatter", "pie"]:
             df = DataFrame(
@@ -2452,7 +2452,7 @@ class TestDataFramePlots:
         "kind", ("line", "bar", "barh", "hist", "kde", "density", "area", "pie")
     )
     def test_group_subplot(self, kind):
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         d = {
             "a": np.arange(10),
             "b": np.arange(10) + 1,
index ff1edd323ef280cef5e7e79aa809906434a86407..5c94c2175aa569825123036220ee78295745d6ca 100644 (file)
@@ -4,6 +4,7 @@ import re
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 import pandas as pd
 from pandas import DataFrame
 import pandas._testing as tm
@@ -14,9 +15,9 @@ from pandas.tests.plotting.common import (
 )
 from pandas.util.version import Version
 
-mpl = pytest.importorskip("matplotlib")
-plt = pytest.importorskip("matplotlib.pyplot")
-cm = pytest.importorskip("matplotlib.cm")
+mpl = td.versioned_importorskip("matplotlib")
+plt = td.versioned_importorskip("matplotlib.pyplot")
+cm = td.versioned_importorskip("matplotlib.cm")
 
 
 def _check_colors_box(bp, box_c, whiskers_c, medians_c, caps_c="k", fliers_c=None):
@@ -446,7 +447,7 @@ class TestDataFrameColor:
         _check_colors(ax.patches[::10], facecolors=["green"] * 5)
 
     def test_kde_colors(self):
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         custom_colors = "rgcby"
         df = DataFrame(np.random.default_rng(2).random((5, 5)))
 
@@ -455,14 +456,14 @@ class TestDataFrameColor:
 
     @pytest.mark.parametrize("colormap", ["jet", cm.jet])
     def test_kde_colors_cmap(self, colormap):
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         df = DataFrame(np.random.default_rng(2).standard_normal((5, 5)))
         ax = df.plot.kde(colormap=colormap)
         rgba_colors = [cm.jet(n) for n in np.linspace(0, 1, len(df))]
         _check_colors(ax.get_lines(), linecolors=rgba_colors)
 
     def test_kde_colors_and_styles_subplots(self):
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         default_colors = _unpack_cycler(mpl.pyplot.rcParams)
 
         df = DataFrame(np.random.default_rng(2).standard_normal((5, 5)))
@@ -473,14 +474,14 @@ class TestDataFrameColor:
 
     @pytest.mark.parametrize("colormap", ["k", "red"])
     def test_kde_colors_and_styles_subplots_single_col_str(self, colormap):
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         df = DataFrame(np.random.default_rng(2).standard_normal((5, 5)))
         axes = df.plot(kind="kde", color=colormap, subplots=True)
         for ax in axes:
             _check_colors(ax.get_lines(), linecolors=[colormap])
 
     def test_kde_colors_and_styles_subplots_custom_color(self):
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         df = DataFrame(np.random.default_rng(2).standard_normal((5, 5)))
         custom_colors = "rgcby"
         axes = df.plot(kind="kde", color=custom_colors, subplots=True)
@@ -489,7 +490,7 @@ class TestDataFrameColor:
 
     @pytest.mark.parametrize("colormap", ["jet", cm.jet])
     def test_kde_colors_and_styles_subplots_cmap(self, colormap):
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         df = DataFrame(np.random.default_rng(2).standard_normal((5, 5)))
         rgba_colors = [cm.jet(n) for n in np.linspace(0, 1, len(df))]
         axes = df.plot(kind="kde", colormap=colormap, subplots=True)
@@ -497,7 +498,7 @@ class TestDataFrameColor:
             _check_colors(ax.get_lines(), linecolors=[c])
 
     def test_kde_colors_and_styles_subplots_single_col(self):
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         df = DataFrame(np.random.default_rng(2).standard_normal((5, 5)))
         # make color a list if plotting one column frame
         # handles cases like df.plot(color='DodgerBlue')
@@ -505,7 +506,7 @@ class TestDataFrameColor:
         _check_colors(axes[0].lines, linecolors=["DodgerBlue"])
 
     def test_kde_colors_and_styles_subplots_single_char(self):
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         df = DataFrame(np.random.default_rng(2).standard_normal((5, 5)))
         # list of styles
         # single character style
@@ -514,7 +515,7 @@ class TestDataFrameColor:
             _check_colors(ax.get_lines(), linecolors=["r"])
 
     def test_kde_colors_and_styles_subplots_list(self):
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         df = DataFrame(np.random.default_rng(2).standard_normal((5, 5)))
         # list of styles
         styles = list("rgcby")
index f1924185a3df1cae2f0df89ec84225cd68f8fa6d..644ce2bb40f1fff8ea059997a6280a71af2b8d40 100644 (file)
@@ -2,10 +2,11 @@
 
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas import DataFrame
 from pandas.tests.plotting.common import _check_visible
 
-pytest.importorskip("matplotlib")
+td.versioned_importorskip("matplotlib")
 
 
 class TestDataFramePlotsGroupby:
index 402a4b9531e5d4857d0d6e9d7cda2c002d0469d4..bb464624693bab220d35afcb7604efd62d4663b8 100644 (file)
@@ -14,7 +14,7 @@ from pandas.tests.plotting.common import (
 )
 from pandas.util.version import Version
 
-mpl = pytest.importorskip("matplotlib")
+mpl = td.versioned_importorskip("matplotlib")
 
 
 class TestFrameLegend:
@@ -61,7 +61,7 @@ class TestFrameLegend:
 
     @pytest.mark.parametrize("kind", ["line", "bar", "barh", "kde", "area", "hist"])
     def test_df_legend_labels(self, kind):
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         df = DataFrame(np.random.default_rng(2).random((3, 3)), columns=["a", "b", "c"])
         df2 = DataFrame(
             np.random.default_rng(2).random((3, 3)), columns=["d", "e", "f"]
@@ -87,7 +87,7 @@ class TestFrameLegend:
         _check_legend_labels(ax, labels=expected)
 
     def test_df_legend_labels_secondary_y(self):
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         df = DataFrame(np.random.default_rng(2).random((3, 3)), columns=["a", "b", "c"])
         df2 = DataFrame(
             np.random.default_rng(2).random((3, 3)), columns=["d", "e", "f"]
@@ -105,7 +105,7 @@ class TestFrameLegend:
 
     def test_df_legend_labels_time_series(self):
         # Time Series
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         ind = date_range("1/1/2014", periods=3)
         df = DataFrame(
             np.random.default_rng(2).standard_normal((3, 3)),
@@ -131,7 +131,7 @@ class TestFrameLegend:
 
     def test_df_legend_labels_time_series_scatter(self):
         # Time Series
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         ind = date_range("1/1/2014", periods=3)
         df = DataFrame(
             np.random.default_rng(2).standard_normal((3, 3)),
@@ -157,7 +157,7 @@ class TestFrameLegend:
         _check_legend_labels(ax, labels=["data1", "data3"])
 
     def test_df_legend_labels_time_series_no_mutate(self):
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         ind = date_range("1/1/2014", periods=3)
         df = DataFrame(
             np.random.default_rng(2).standard_normal((3, 3)),
index 46b9cea2ff74a077b2e6ba3b34bc90c6a908843b..a7de569d24480211bc26bd4ad3dc7b809b90a187 100644 (file)
@@ -6,6 +6,7 @@ import numpy as np
 from numpy.testing import assert_array_almost_equal_nulp
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas.compat import is_platform_linux
 from pandas.compat.numpy import np_version_gte1p24
 
@@ -27,8 +28,8 @@ from pandas.tests.plotting.common import (
 
 from pandas.io.formats.printing import pprint_thing
 
-mpl = pytest.importorskip("matplotlib")
-plt = pytest.importorskip("matplotlib.pyplot")
+mpl = td.versioned_importorskip("matplotlib")
+plt = td.versioned_importorskip("matplotlib.pyplot")
 
 
 class TestDataFramePlotsSubplots:
index a9250fa8347cc04fa34c28b016e1fb27d837284f..e8afa0e2080681e0f6ee08b408e7e12179de1d9b 100644 (file)
@@ -3,6 +3,7 @@ import re
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas import DataFrame
 import pandas._testing as tm
 from pandas.tests.plotting.common import (
@@ -12,7 +13,7 @@ from pandas.tests.plotting.common import (
     get_y_axis,
 )
 
-pytest.importorskip("matplotlib")
+td.versioned_importorskip("matplotlib")
 
 
 @pytest.fixture
index e1b03a34086c03c01d7fa6cd4b3158a444d17e09..f27cb7ff72c69adc048dfac07127f859e664a465 100644 (file)
@@ -8,6 +8,7 @@ import string
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas import (
     DataFrame,
     MultiIndex,
@@ -28,8 +29,8 @@ from pandas.util.version import Version
 
 from pandas.io.formats.printing import pprint_thing
 
-mpl = pytest.importorskip("matplotlib")
-plt = pytest.importorskip("matplotlib.pyplot")
+mpl = td.versioned_importorskip("matplotlib")
+plt = td.versioned_importorskip("matplotlib.pyplot")
 
 
 def _check_ax_limits(col, ax):
index 20daf5935624843af3224f991497f84fa6639a0d..8d58408ace5a221cffd66ff6bdd50a25add1bb8b 100644 (file)
@@ -1,5 +1,6 @@
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas import DataFrame
 from pandas.tests.plotting.common import (
     _check_plot_works,
@@ -7,7 +8,7 @@ from pandas.tests.plotting.common import (
     _gen_two_subplots,
 )
 
-plt = pytest.importorskip("matplotlib.pyplot")
+plt = td.versioned_importorskip("matplotlib.pyplot")
 
 
 class TestCommon:
index f748d7c5fc758045fc5d3475b94e376a06f5269b..69784259616bd2a4c7817b3b57bb1a6c16579efc 100644 (file)
@@ -8,6 +8,7 @@ import sys
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 import pandas._config.config as cf
 
 from pandas._libs.tslibs import to_offset
@@ -41,8 +42,8 @@ except ImportError:
     # causing an improper skip
     pass
 
-pytest.importorskip("matplotlib.pyplot")
-dates = pytest.importorskip("matplotlib.dates")
+td.versioned_importorskip("matplotlib.pyplot")
+dates = td.versioned_importorskip("matplotlib.dates")
 
 
 @pytest.mark.single_cpu
@@ -79,7 +80,7 @@ class TestRegistration:
         assert subprocess.check_call(call) == 0
 
     def test_registering_no_warning(self):
-        plt = pytest.importorskip("matplotlib.pyplot")
+        plt = td.versioned_importorskip("matplotlib.pyplot")
         s = Series(range(12), index=date_range("2017", periods=12))
         _, ax = plt.subplots()
 
@@ -89,7 +90,7 @@ class TestRegistration:
         plt.close()
 
     def test_pandas_plots_register(self):
-        plt = pytest.importorskip("matplotlib.pyplot")
+        plt = td.versioned_importorskip("matplotlib.pyplot")
         s = Series(range(12), index=date_range("2017", periods=12))
         # Set to the "warn" state, in case this isn't the first test run
         with tm.assert_produces_warning(None) as w:
@@ -101,7 +102,7 @@ class TestRegistration:
             plt.close()
 
     def test_matplotlib_formatters(self):
-        units = pytest.importorskip("matplotlib.units")
+        units = td.versioned_importorskip("matplotlib.units")
 
         # Can't make any assertion about the start state.
         # We we check that toggling converters off removes it, and toggling it
@@ -113,9 +114,9 @@ class TestRegistration:
             assert Timestamp in units.registry
 
     def test_option_no_warning(self):
-        pytest.importorskip("matplotlib.pyplot")
+        td.versioned_importorskip("matplotlib.pyplot")
         ctx = cf.option_context("plotting.matplotlib.register_converters", False)
-        plt = pytest.importorskip("matplotlib.pyplot")
+        plt = td.versioned_importorskip("matplotlib.pyplot")
         s = Series(range(12), index=date_range("2017", periods=12))
         _, ax = plt.subplots()
 
@@ -130,8 +131,8 @@ class TestRegistration:
         plt.close()
 
     def test_registry_resets(self):
-        units = pytest.importorskip("matplotlib.units")
-        dates = pytest.importorskip("matplotlib.dates")
+        units = td.versioned_importorskip("matplotlib.units")
+        dates = td.versioned_importorskip("matplotlib.dates")
 
         # make a copy, to reset to
         original = dict(units.registry)
index 6c318402ea226a09fbd4b9278343ef914f8fc83a..65bb6354306c590c0f83668d2682505ec2b245fe 100644 (file)
@@ -10,6 +10,7 @@ import pickle
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas._libs.tslibs import (
     BaseOffset,
     to_offset,
@@ -41,7 +42,7 @@ from pandas.tests.plotting.common import _check_ticks_props
 
 from pandas.tseries.offsets import WeekOfMonth
 
-mpl = pytest.importorskip("matplotlib")
+mpl = td.versioned_importorskip("matplotlib")
 
 
 class TestTSPlot:
@@ -737,7 +738,7 @@ class TestTSPlot:
         assert ax.get_yaxis().get_visible()
 
     def test_secondary_kde(self):
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         ser = Series(np.random.default_rng(2).standard_normal(10))
         fig, ax = mpl.pyplot.subplots()
         ax = ser.plot(secondary_y=True, kind="density", ax=ax)
index 5ebf93510a61549c838d91ab2e703f9db23fd626..ad901abb8255d2fc25c8545cdc3777e875806cf3 100644 (file)
@@ -4,6 +4,7 @@
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas import (
     DataFrame,
     Index,
@@ -14,7 +15,7 @@ from pandas.tests.plotting.common import (
     _check_legend_labels,
 )
 
-pytest.importorskip("matplotlib")
+td.versioned_importorskip("matplotlib")
 
 
 class TestDataFrameGroupByPlots:
index 4d17f87fdc7bc1456a118c84b76c631544572fd4..773bc762a92acd84f47eb1d8b5395f3c87fde3c0 100644 (file)
@@ -4,6 +4,7 @@ import re
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas import (
     DataFrame,
     Index,
@@ -25,7 +26,7 @@ from pandas.tests.plotting.common import (
     get_y_axis,
 )
 
-mpl = pytest.importorskip("matplotlib")
+mpl = td.versioned_importorskip("matplotlib")
 
 
 @pytest.fixture
@@ -206,7 +207,7 @@ class TestSeriesPlots:
 
     @pytest.mark.xfail(reason="Api changed in 3.6.0")
     def test_hist_kde(self, ts):
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         _, ax = mpl.pyplot.subplots()
         ax = ts.plot.hist(logy=True, ax=ax)
         _check_ax_scales(ax, yaxis="log")
@@ -217,16 +218,16 @@ class TestSeriesPlots:
         _check_text_labels(ylabels, [""] * len(ylabels))
 
     def test_hist_kde_plot_works(self, ts):
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         _check_plot_works(ts.plot.kde)
 
     def test_hist_kde_density_works(self, ts):
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         _check_plot_works(ts.plot.density)
 
     @pytest.mark.xfail(reason="Api changed in 3.6.0")
     def test_hist_kde_logy(self, ts):
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         _, ax = mpl.pyplot.subplots()
         ax = ts.plot.kde(logy=True, ax=ax)
         _check_ax_scales(ax, yaxis="log")
@@ -236,7 +237,7 @@ class TestSeriesPlots:
         _check_text_labels(ylabels, [""] * len(ylabels))
 
     def test_hist_kde_color_bins(self, ts):
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         _, ax = mpl.pyplot.subplots()
         ax = ts.plot.hist(logy=True, bins=10, color="b", ax=ax)
         _check_ax_scales(ax, yaxis="log")
@@ -244,7 +245,7 @@ class TestSeriesPlots:
         _check_colors(ax.patches, facecolors=["b"] * 10)
 
     def test_hist_kde_color(self, ts):
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         _, ax = mpl.pyplot.subplots()
         ax = ts.plot.kde(logy=True, color="r", ax=ax)
         _check_ax_scales(ax, yaxis="log")
@@ -631,7 +632,7 @@ class TestDataFramePlots:
 
     def test_hist_with_nans_and_weights(self):
         # GH 48884
-        mpl_patches = pytest.importorskip("matplotlib.patches")
+        mpl_patches = td.versioned_importorskip("matplotlib.patches")
         df = DataFrame(
             [[np.nan, 0.2, 0.3], [0.4, np.nan, np.nan], [0.7, 0.8, 0.9]],
             columns=list("abc"),
index cfb657c2a800fefe2d509ddfb398399af4ce8649..b98663c63b8b3efc4dc38651caf6ac95036bf280 100644 (file)
@@ -26,9 +26,9 @@ from pandas.tests.plotting.common import (
     _check_ticks_props,
 )
 
-mpl = pytest.importorskip("matplotlib")
-plt = pytest.importorskip("matplotlib.pyplot")
-cm = pytest.importorskip("matplotlib.cm")
+mpl = td.versioned_importorskip("matplotlib")
+plt = td.versioned_importorskip("matplotlib.pyplot")
+cm = td.versioned_importorskip("matplotlib.cm")
 
 
 @pytest.fixture
@@ -148,7 +148,7 @@ class TestSeriesPlots:
 class TestDataFramePlots:
     @pytest.mark.parametrize("pass_axis", [False, True])
     def test_scatter_matrix_axis(self, pass_axis):
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         scatter_matrix = plotting.scatter_matrix
 
         ax = None
@@ -173,7 +173,7 @@ class TestDataFramePlots:
 
     @pytest.mark.parametrize("pass_axis", [False, True])
     def test_scatter_matrix_axis_smaller(self, pass_axis):
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         scatter_matrix = plotting.scatter_matrix
 
         ax = None
index 2b2f2f3b84307b9ed69e440d2ac0112abf153e67..4aac755a775116fa3519248939a8d3c52f132adf 100644 (file)
@@ -32,8 +32,8 @@ from pandas.tests.plotting.common import (
     get_y_axis,
 )
 
-mpl = pytest.importorskip("matplotlib")
-plt = pytest.importorskip("matplotlib.pyplot")
+mpl = td.versioned_importorskip("matplotlib")
+plt = td.versioned_importorskip("matplotlib.pyplot")
 
 
 @pytest.fixture
@@ -569,16 +569,16 @@ class TestSeriesPlots:
         ],
     )
     def test_kde_kwargs(self, ts, bw_method, ind):
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         _check_plot_works(ts.plot.kde, bw_method=bw_method, ind=ind)
 
     def test_density_kwargs(self, ts):
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         sample_points = np.linspace(-100, 100, 20)
         _check_plot_works(ts.plot.density, bw_method=0.5, ind=sample_points)
 
     def test_kde_kwargs_check_axes(self, ts):
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         _, ax = mpl.pyplot.subplots()
         sample_points = np.linspace(-100, 100, 20)
         ax = ts.plot.kde(logy=True, bw_method=0.5, ind=sample_points, ax=ax)
@@ -586,7 +586,7 @@ class TestSeriesPlots:
         _check_text_labels(ax.yaxis.get_label(), "Density")
 
     def test_kde_missing_vals(self):
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         s = Series(np.random.default_rng(2).uniform(size=50))
         s[0] = np.nan
         axes = _check_plot_works(s.plot.kde)
@@ -609,7 +609,7 @@ class TestSeriesPlots:
         plotting.PlotAccessor._common_kinds + plotting.PlotAccessor._series_kinds,
     )
     def test_kind_kwarg(self, kind):
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         s = Series(range(3))
         _, ax = mpl.pyplot.subplots()
         s.plot(kind=kind, ax=ax)
@@ -620,7 +620,7 @@ class TestSeriesPlots:
         plotting.PlotAccessor._common_kinds + plotting.PlotAccessor._series_kinds,
     )
     def test_kind_attr(self, kind):
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         s = Series(range(3))
         _, ax = mpl.pyplot.subplots()
         getattr(s.plot, kind)()
@@ -636,7 +636,7 @@ class TestSeriesPlots:
 
     @pytest.mark.parametrize("kind", plotting.PlotAccessor._common_kinds)
     def test_valid_object_plot(self, kind):
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         s = Series(range(10), dtype=object)
         _check_plot_works(s.plot, kind=kind)
 
@@ -750,7 +750,7 @@ class TestSeriesPlots:
     @pytest.mark.slow
     def test_series_grid_settings(self):
         # Make sure plot defaults to rcParams['axes.grid'] setting, GH 9792
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         _check_grid_settings(
             Series([1, 2, 3]),
             plotting.PlotAccessor._series_kinds + plotting.PlotAccessor._common_kinds,
index 665bda15724fd67dc9917509d2b95957b03107e3..6c64e46d34d5b57ffb0504d2b8453133e5bf179a 100644 (file)
@@ -1,8 +1,9 @@
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas import Series
 
-pytest.importorskip("matplotlib")
+td.versioned_importorskip("matplotlib")
 from pandas.plotting._matplotlib.style import get_standard_colors
 
 
index 8fbb78737474c8abf34b8720603e32f6a93d83e7..44a01205dc8a4b37a009b9fa321067d8c0baaf04 100644 (file)
@@ -6,6 +6,7 @@ import inspect
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 import pandas as pd
 from pandas import (
     DataFrame,
@@ -231,7 +232,7 @@ class TestSeriesStatReductions:
         assert pd.isna(result)
 
     def test_skew(self):
-        sp_stats = pytest.importorskip("scipy.stats")
+        sp_stats = td.versioned_importorskip("scipy.stats")
 
         string_series = Series(range(20), dtype=np.float64, name="series")
 
@@ -253,7 +254,7 @@ class TestSeriesStatReductions:
                 assert (df.skew() == 0).all()
 
     def test_kurt(self):
-        sp_stats = pytest.importorskip("scipy.stats")
+        sp_stats = td.versioned_importorskip("scipy.stats")
 
         string_series = Series(range(20), dtype=np.float64, name="series")
 
index a9701b7ecd607ad9e25842edd7bd8991f47bda00..60227db0b49fc7ae1fe3afc956f990724909ab41 100644 (file)
@@ -1104,7 +1104,7 @@ def test_resample_dtype_preservation(unit):
 
 
 def test_resample_dtype_coercion(unit):
-    pytest.importorskip("scipy.interpolate")
+    td.versioned_importorskip("scipy.interpolate")
 
     # GH 16361
     df = {"a": [1, 3, 1, 4]}
index c8292afe3c0fe7b74db647037de4b1601f6a7581..6c6303b3f8c02dba8fe05ed6030710b3c9907c18 100644 (file)
@@ -10,6 +10,7 @@ import pytest
 
 from pandas.compat import PY314
 
+import pandas.util._test_decorators as td
 from pandas.core.dtypes.common import (
     is_object_dtype,
     is_string_dtype,
@@ -2827,7 +2828,7 @@ def test_merge_ea_and_non_ea(any_numeric_ea_dtype, join_type):
 @pytest.mark.parametrize("dtype", ["int64", "int64[pyarrow]"])
 def test_merge_arrow_and_numpy_dtypes(dtype):
     # GH#52406
-    pytest.importorskip("pyarrow")
+    td.versioned_importorskip("pyarrow")
     df = DataFrame({"a": [1, 2]}, dtype=dtype)
     df2 = DataFrame({"a": [1, 2]}, dtype="int64[pyarrow]")
     result = df.merge(df2)
@@ -2977,7 +2978,7 @@ def test_merge_ea_int_and_float_numpy():
 
 def test_merge_arrow_string_index(any_string_dtype):
     # GH#54894
-    pytest.importorskip("pyarrow")
+    td.versioned_importorskip("pyarrow")
     left = DataFrame({"a": ["a", "b"]}, dtype=any_string_dtype)
     right = DataFrame({"b": 1}, index=Index(["a", "c"], dtype=any_string_dtype))
     result = left.merge(right, left_on="a", right_index=True, how="left")
index 1c60567c1a5300dd4118ae729c3c784eabd4d747..77435d5df6ba4079c20108998f4781cabb926ef1 100644 (file)
@@ -2,13 +2,14 @@ import re
 
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas import (
     ArrowDtype,
     Series,
 )
 import pandas._testing as tm
 
-pa = pytest.importorskip("pyarrow")
+pa = td.versioned_importorskip("pyarrow")
 
 from pandas.compat import pa_version_under11p0
 
index 80aea75fda406cf77e0fda73a6d9849c393e7d83..5d4fcf459fa2c51e5ae9c289a4943b743a851842 100644 (file)
@@ -2,6 +2,7 @@ import re
 
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas.compat.pyarrow import (
     pa_version_under11p0,
     pa_version_under13p0,
@@ -15,8 +16,8 @@ from pandas import (
 )
 import pandas._testing as tm
 
-pa = pytest.importorskip("pyarrow")
-pc = pytest.importorskip("pyarrow.compute")
+pa = td.versioned_importorskip("pyarrow")
+pc = td.versioned_importorskip("pyarrow.compute")
 
 
 def test_struct_accessor_dtypes():
index c2cc838619790c848f9b707dae2f46785972ec49..e40fdad452e3357982c17e7d36ae866f6282cd3a 100644 (file)
@@ -3,6 +3,7 @@ from itertools import product
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas._config import using_string_dtype
 
 from pandas._libs import lib
@@ -294,7 +295,7 @@ class TestSeriesConvertDtypes:
 
     def test_convert_dtypes_pyarrow_to_np_nullable(self):
         # GH 53648
-        pytest.importorskip("pyarrow")
+        td.versioned_importorskip("pyarrow")
         ser = pd.Series(range(2), dtype="int32[pyarrow]")
         result = ser.convert_dtypes(dtype_backend="numpy_nullable")
         expected = pd.Series(range(2), dtype="Int32")
@@ -302,7 +303,7 @@ class TestSeriesConvertDtypes:
 
     def test_convert_dtypes_pyarrow_null(self):
         # GH#55346
-        pa = pytest.importorskip("pyarrow")
+        pa = td.versioned_importorskip("pyarrow")
         ser = pd.Series([None, None])
         result = ser.convert_dtypes(dtype_backend="pyarrow")
         expected = pd.Series([None, None], dtype=pd.ArrowDtype(pa.null()))
index a369145b4e884d740af39b236edbf2ce6e088cd0..2d769a4c7bc54325c085e487eb2996db1750cd72 100644 (file)
@@ -3,6 +3,7 @@ import math
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 import pandas as pd
 from pandas import (
     Series,
@@ -58,7 +59,7 @@ class TestSeriesCov:
 class TestSeriesCorr:
     @pytest.mark.parametrize("dtype", ["float64", "Float64"])
     def test_corr(self, datetime_series, dtype):
-        stats = pytest.importorskip("scipy.stats")
+        stats = td.versioned_importorskip("scipy.stats")
 
         datetime_series = datetime_series.astype(dtype)
 
@@ -93,7 +94,7 @@ class TestSeriesCorr:
         tm.assert_almost_equal(result, expected)
 
     def test_corr_rank(self):
-        stats = pytest.importorskip("scipy.stats")
+        stats = td.versioned_importorskip("scipy.stats")
 
         # kendall and spearman
         A = Series(
index 10b2e98586365929e4ff05df0d93660d55cf8850..91b6e6bf967015521e7754691bb75c0c3a822637 100644 (file)
@@ -1,6 +1,7 @@
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 import pandas as pd
 from pandas import (
     Categorical,
@@ -252,7 +253,7 @@ class TestSeriesDropDuplicates:
         tm.assert_series_equal(result, expected)
 
     def test_duplicated_arrow_dtype(self):
-        pytest.importorskip("pyarrow")
+        td.versioned_importorskip("pyarrow")
         ser = Series([True, False, None, False], dtype="bool[pyarrow]")
         result = ser.drop_duplicates()
         expected = Series([True, False, None], dtype="bool[pyarrow]")
@@ -260,7 +261,7 @@ class TestSeriesDropDuplicates:
 
     def test_drop_duplicates_arrow_strings(self):
         # GH#54904
-        pa = pytest.importorskip("pyarrow")
+        pa = td.versioned_importorskip("pyarrow")
         ser = Series(["a", "a"], dtype=pd.ArrowDtype(pa.string()))
         result = ser.drop_duplicates()
         expecetd = Series(["a"], dtype=pd.ArrowDtype(pa.string()))
index f14f31384facb644e8814fe0cb34021452ac24be..64ba4a90fc4cdcbf9a130a594596e05737823ea0 100644 (file)
@@ -1,6 +1,7 @@
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 import pandas as pd
 import pandas._testing as tm
 
@@ -146,7 +147,7 @@ def test_explode_scalars_can_ignore_index():
 @pytest.mark.parametrize("ignore_index", [True, False])
 def test_explode_pyarrow_list_type(ignore_index):
     # GH 53602
-    pa = pytest.importorskip("pyarrow")
+    pa = td.versioned_importorskip("pyarrow")
 
     data = [
         [None, None],
@@ -167,7 +168,7 @@ def test_explode_pyarrow_list_type(ignore_index):
 
 @pytest.mark.parametrize("ignore_index", [True, False])
 def test_explode_pyarrow_non_list_type(ignore_index):
-    pa = pytest.importorskip("pyarrow")
+    pa = td.versioned_importorskip("pyarrow")
     data = [1, 2, 3]
     ser = pd.Series(data, dtype=pd.ArrowDtype(pa.int64()))
     result = ser.explode(ignore_index=ignore_index)
index d854f0b7877595fba5ac0050a281aa3708240b0e..1886b973d76725c780d0e5da9e5b05e460412b35 100644 (file)
@@ -118,7 +118,7 @@ class TestSeriesInterpolateData:
             non_ts.interpolate(method="time")
 
     def test_interpolate_cubicspline(self):
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         ser = Series([10, 11, 12, 13])
 
         expected = Series(
@@ -133,7 +133,7 @@ class TestSeriesInterpolateData:
         tm.assert_series_equal(result, expected)
 
     def test_interpolate_pchip(self):
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         ser = Series(np.sort(np.random.default_rng(2).uniform(size=100)))
 
         # interpolate at new_index
@@ -145,7 +145,7 @@ class TestSeriesInterpolateData:
         interp_s.loc[49:51]
 
     def test_interpolate_akima(self):
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         ser = Series([10, 11, 12, 13])
 
         # interpolate at new_index where `der` is zero
@@ -171,7 +171,7 @@ class TestSeriesInterpolateData:
         tm.assert_series_equal(interp_s.loc[1:3], expected)
 
     def test_interpolate_piecewise_polynomial(self):
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         ser = Series([10, 11, 12, 13])
 
         expected = Series(
@@ -186,7 +186,7 @@ class TestSeriesInterpolateData:
         tm.assert_series_equal(interp_s.loc[1:3], expected)
 
     def test_interpolate_from_derivatives(self):
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         ser = Series([10, 11, 12, 13])
 
         expected = Series(
@@ -276,14 +276,14 @@ class TestSeriesInterpolateData:
         tm.assert_series_equal(result, expected)
 
     def test_interp_quad(self):
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         sq = Series([1, 4, np.nan, 16], index=[1, 2, 3, 4])
         result = sq.interpolate(method="quadratic")
         expected = Series([1.0, 4.0, 9.0, 16.0], index=[1, 2, 3, 4])
         tm.assert_series_equal(result, expected)
 
     def test_interp_scipy_basic(self):
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         s = Series([1, 3, np.nan, 12, np.nan, 25])
         # slinear
         expected = Series([1.0, 3.0, 7.5, 12.0, 18.5, 25.0])
@@ -618,7 +618,7 @@ class TestSeriesInterpolateData:
         tm.assert_series_equal(result, expected)
 
     def test_interp_all_good(self):
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         s = Series([1, 2, 3])
         result = s.interpolate(method="polynomial", order=1)
         tm.assert_series_equal(result, s)
@@ -645,7 +645,7 @@ class TestSeriesInterpolateData:
                 s.interpolate(method="polynomial", order=1)
 
     def test_interp_nonmono_raise(self):
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         s = Series([1, np.nan, 3], index=[0, 2, 1])
         msg = "krogh interpolation requires that the index be monotonic"
         with pytest.raises(ValueError, match=msg):
@@ -653,7 +653,7 @@ class TestSeriesInterpolateData:
 
     @pytest.mark.parametrize("method", ["nearest", "pad"])
     def test_interp_datetime64(self, method, tz_naive_fixture):
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         df = Series(
             [1, np.nan, 3], index=date_range("1/1/2000", periods=3, tz=tz_naive_fixture)
         )
@@ -699,7 +699,7 @@ class TestSeriesInterpolateData:
     @pytest.mark.parametrize("method", ["polynomial", "spline"])
     def test_no_order(self, method):
         # see GH-10633, GH-24014
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         s = Series([0, 1, np.nan, 3])
         msg = "You must specify the order of the spline or polynomial"
         with pytest.raises(ValueError, match=msg):
@@ -707,21 +707,21 @@ class TestSeriesInterpolateData:
 
     @pytest.mark.parametrize("order", [-1, -1.0, 0, 0.0, np.nan])
     def test_interpolate_spline_invalid_order(self, order):
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         s = Series([0, 1, np.nan, 3])
         msg = "order needs to be specified and greater than 0"
         with pytest.raises(ValueError, match=msg):
             s.interpolate(method="spline", order=order)
 
     def test_spline(self):
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         s = Series([1, 2, np.nan, 4, 5, np.nan, 7])
         result = s.interpolate(method="spline", order=1)
         expected = Series([1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0])
         tm.assert_series_equal(result, expected)
 
     def test_spline_extrapolate(self):
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         s = Series([1, 2, 3, 4, np.nan, 6, np.nan])
         result3 = s.interpolate(method="spline", order=1, ext=3)
         expected3 = Series([1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 6.0])
@@ -732,7 +732,7 @@ class TestSeriesInterpolateData:
         tm.assert_series_equal(result1, expected1)
 
     def test_spline_smooth(self):
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         s = Series([1, 2, np.nan, 4, 5.1, np.nan, 7])
         assert (
             s.interpolate(method="spline", order=3, s=0)[5]
@@ -741,7 +741,7 @@ class TestSeriesInterpolateData:
 
     def test_spline_interpolation(self):
         # Explicit cast to float to avoid implicit cast when setting np.nan
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         s = Series(np.arange(10) ** 2, dtype="float")
         s[np.random.default_rng(2).integers(0, 9, 3)] = np.nan
         result1 = s.interpolate(method="spline", order=1)
@@ -801,7 +801,7 @@ class TestSeriesInterpolateData:
 
         method, kwargs = interp_methods_ind
         if method == "pchip":
-            pytest.importorskip("scipy")
+            td.versioned_importorskip("scipy")
 
         if method == "linear":
             result = df[0].interpolate(**kwargs)
@@ -824,7 +824,7 @@ class TestSeriesInterpolateData:
         are tested here.
         """
         # gh 21662
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         ind = pd.timedelta_range(start=1, periods=4)
         df = pd.DataFrame([0, 1, np.nan, 3], index=ind)
 
@@ -861,7 +861,7 @@ class TestSeriesInterpolateData:
 
     def test_interpolate_fill_value(self):
         # GH#54920
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         ser = Series([np.nan, 0, 1, np.nan, 3, np.nan])
         result = ser.interpolate(method="nearest", fill_value=0)
         expected = Series([np.nan, 0, 1, 1, 3, 0])
index 1c3ebe5653ce3d62f5cf7d13dc1be14f86a7de9a..7d3f2fc123060cefc70c0c513ccb214c7b57252b 100644 (file)
@@ -74,7 +74,7 @@ def expected_dtype(dtype, method, pct=False):
 
 class TestSeriesRank:
     def test_rank(self, datetime_series):
-        sp_stats = pytest.importorskip("scipy.stats")
+        sp_stats = td.versioned_importorskip("scipy.stats")
 
         datetime_series[::2] = np.nan
         datetime_series[:10:3] = 4.0
@@ -293,7 +293,7 @@ class TestSeriesRank:
     def test_rank_tie_methods_on_infs_nans(
         self, method, na_option, ascending, dtype, na_value, pos_inf, neg_inf
     ):
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         if dtype == "float64[pyarrow]":
             if method == "average":
                 exp_dtype = "float64[pyarrow]"
@@ -342,7 +342,7 @@ class TestSeriesRank:
         ],
     )
     def test_rank_methods_series(self, method, op, value):
-        sp_stats = pytest.importorskip("scipy.stats")
+        sp_stats = td.versioned_importorskip("scipy.stats")
 
         xs = np.random.default_rng(2).standard_normal(9)
         xs = np.concatenate([xs[i:] for i in range(0, 9, 2)])  # add duplicates
index fa571fa126b38282cd5e132472a3824732446354..7ea6eed93a72b9a9a91a55d3777f552c121115da 100644 (file)
@@ -3,6 +3,7 @@ from datetime import datetime
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 import pandas as pd
 from pandas import (
     DataFrame,
@@ -170,7 +171,7 @@ class TestResetIndex:
 
     def test_reset_index_drop_infer_string(self):
         # GH#56160
-        pytest.importorskip("pyarrow")
+        td.versioned_importorskip("pyarrow")
         ser = Series(["a", "b", "c"], dtype=object)
         with option_context("future.infer_string", True):
             result = ser.reset_index(drop=True)
index 10588c3b744f287451a971dfd17eda7d7421d1f8..0ea5a9b942af4b3e02256a0ae50ff17a62317415 100644 (file)
@@ -6,6 +6,7 @@ from datetime import (
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 import pandas as pd
 from pandas import (
     Categorical,
@@ -227,7 +228,7 @@ class TestSeriesRepr:
         repr(ts2).splitlines()[-1]
 
     def test_latex_repr(self):
-        pytest.importorskip("jinja2")  # uses Styler implementation
+        td.versioned_importorskip("jinja2")  # uses Styler implementation
         result = r"""\begin{tabular}{ll}
 \toprule
  & 0 \\
index 8d7adc1c1aae644136561a8813b9cd7871d60b36..5efcba74865d2429bde9b26296373ec1d18ed98f 100644 (file)
@@ -4,6 +4,7 @@ import operator
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas._config import using_string_dtype
 
 from pandas import (
@@ -533,7 +534,7 @@ class TestSeriesLogicalOps:
     # TODO: this belongs in comparison tests
     def test_pyarrow_numpy_string_invalid(self):
         # GH#56008
-        pa = pytest.importorskip("pyarrow")
+        pa = td.versioned_importorskip("pyarrow")
         ser = Series([False, True])
         ser2 = Series(["a", "b"], dtype=StringDtype(na_value=np.nan))
         result = ser == ser2
index 5415f220cadd427c244a78c6f5619972f3a12a78..d9e9c894c588cab7899ae6856c933702a17e8842 100644 (file)
@@ -1,6 +1,7 @@
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 import pandas as pd
 from pandas import Series
 import pandas._testing as tm
@@ -53,7 +54,7 @@ def test_mode_nullable_dtype(any_numeric_ea_dtype):
 
 def test_mode_infer_string():
     # GH#56183
-    pytest.importorskip("pyarrow")
+    td.versioned_importorskip("pyarrow")
     ser = Series(["a", "b"], dtype=object)
     with pd.option_context("future.infer_string", True):
         result = ser.mode()
index 77d008c650264889550ec70331a1b98064242d26..c01c1f68f4288b421b906d58ad56cacde17d2b5c 100644 (file)
@@ -4,6 +4,7 @@ import re
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas.core.dtypes.dtypes import ArrowDtype
 
 from pandas import (
@@ -718,7 +719,7 @@ def test_extractall_same_as_extract_subject_index(any_string_dtype):
 def test_extractall_preserves_dtype():
     # Ensure that when extractall is called on a series with specific dtypes set, that
     # the dtype is preserved in the resulting DataFrame's column.
-    pa = pytest.importorskip("pyarrow")
+    pa = td.versioned_importorskip("pyarrow")
 
     result = Series(["abc", "ab"], dtype=ArrowDtype(pa.string())).str.extractall("(ab)")
     assert result.dtypes[0] == "string[pyarrow]"
index 80ee0f6e067f97e1177db1f0663d4cfd8e0d3324..d040e2790cbdeec70a7ec6eecdf547fcc59e1f1a 100644 (file)
@@ -4,6 +4,7 @@ import struct
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas._config import using_string_dtype
 
 from pandas._libs import (
@@ -1804,7 +1805,7 @@ class TestRank:
         ],
     )
     def test_scipy_compat(self, arr):
-        sp_stats = pytest.importorskip("scipy.stats")
+        sp_stats = td.versioned_importorskip("scipy.stats")
 
         arr = np.array(arr)
 
index bf64bd2a2ae0c2fea291b5f1f34d6f487add999b..c46c090423cf3369bde6c08d2216477d4d4b2bb8 100644 (file)
@@ -44,8 +44,8 @@ def test_dask(df):
     olduse = pd.get_option("compute.use_numexpr")
 
     try:
-        pytest.importorskip("toolz")
-        dd = pytest.importorskip("dask.dataframe")
+        td.versioned_importorskip("toolz")
+        dd = td.versioned_importorskip("dask.dataframe")
 
         ddf = dd.from_pandas(df, npartitions=3)
         assert ddf.A is not None
@@ -60,8 +60,8 @@ def test_dask_ufunc():
     olduse = pd.get_option("compute.use_numexpr")
 
     try:
-        da = pytest.importorskip("dask.array")
-        dd = pytest.importorskip("dask.dataframe")
+        da = td.versioned_importorskip("dask.array")
+        dd = td.versioned_importorskip("dask.dataframe")
 
         s = Series([1.5, 2.3, 3.7, 4.0])
         ds = dd.from_pandas(s, npartitions=2)
@@ -76,7 +76,7 @@ def test_dask_ufunc():
 def test_construct_dask_float_array_int_dtype_match_ndarray():
     # GH#40110 make sure we treat a float-dtype dask array with the same
     #  rules we would for an ndarray
-    dd = pytest.importorskip("dask.dataframe")
+    dd = td.versioned_importorskip("dask.dataframe")
 
     arr = np.array([1, 2.5, 3])
     darr = dd.from_array(arr)
@@ -100,15 +100,15 @@ def test_construct_dask_float_array_int_dtype_match_ndarray():
 
 
 def test_xarray(df):
-    pytest.importorskip("xarray")
+    td.versioned_importorskip("xarray")
 
     assert df.to_xarray() is not None
 
 
 def test_xarray_cftimeindex_nearest():
     # https://github.com/pydata/xarray/issues/3751
-    cftime = pytest.importorskip("cftime")
-    xarray = pytest.importorskip("xarray")
+    cftime = td.versioned_importorskip("cftime")
+    xarray = td.versioned_importorskip("xarray")
 
     times = xarray.cftime_range("0001", periods=2)
     key = cftime.DatetimeGregorian(2000, 1, 1)
@@ -140,7 +140,7 @@ def test_oo_optimized_datetime_index_unpickle():
 
 
 def test_statsmodels():
-    smf = pytest.importorskip("statsmodels.formula.api")
+    smf = td.versioned_importorskip("statsmodels.formula.api")
 
     df = DataFrame(
         {"Lottery": range(5), "Literacy": range(5), "Pop1831": range(100, 105)}
@@ -149,7 +149,7 @@ def test_statsmodels():
 
 
 def test_scikit_learn():
-    pytest.importorskip("sklearn")
+    td.versioned_importorskip("sklearn")
     from sklearn import (
         datasets,
         svm,
@@ -162,7 +162,7 @@ def test_scikit_learn():
 
 
 def test_seaborn():
-    seaborn = pytest.importorskip("seaborn")
+    seaborn = td.versioned_importorskip("seaborn")
     tips = DataFrame(
         {"day": pd.date_range("2023", freq="D", periods=5), "total_bill": range(5)}
     )
@@ -170,12 +170,12 @@ def test_seaborn():
 
 
 def test_pandas_datareader():
-    pytest.importorskip("pandas_datareader")
+    td.versioned_importorskip("pandas_datareader")
 
 
 @pytest.mark.filterwarnings("ignore:Passing a BlockManager:DeprecationWarning")
 def test_pyarrow(df):
-    pyarrow = pytest.importorskip("pyarrow")
+    pyarrow = td.versioned_importorskip("pyarrow")
     table = pyarrow.Table.from_pandas(df)
     result = table.to_pandas()
     tm.assert_frame_equal(result, df)
@@ -183,7 +183,7 @@ def test_pyarrow(df):
 
 def test_yaml_dump(df):
     # GH#42748
-    yaml = pytest.importorskip("yaml")
+    yaml = td.versioned_importorskip("yaml")
 
     dumped = yaml.dump(df)
 
@@ -245,8 +245,8 @@ def test_frame_setitem_dask_array_into_new_col(request):
     olduse = pd.get_option("compute.use_numexpr")
 
     try:
-        dask = pytest.importorskip("dask")
-        da = pytest.importorskip("dask.array")
+        dask = td.versioned_importorskip("dask")
+        da = td.versioned_importorskip("dask.array")
         if Version(dask.__version__) <= Version("2025.1.0") and Version(
             np.__version__
         ) >= Version("2.1"):
@@ -353,7 +353,7 @@ def test_dataframe_consortium() -> None:
     Full testing is done at https://github.com/data-apis/dataframe-api-compat,
     this is just to check that the entry point works as expected.
     """
-    pytest.importorskip("dataframe_api_compat")
+    td.versioned_importorskip("dataframe_api_compat")
     df_pd = DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]})
     df = df_pd.__dataframe_consortium_standard__()
     result_1 = df.get_column_names()
@@ -367,7 +367,7 @@ def test_dataframe_consortium() -> None:
 
 def test_xarray_coerce_unit():
     # GH44053
-    xr = pytest.importorskip("xarray")
+    xr = td.versioned_importorskip("xarray")
 
     arr = xr.DataArray([1, 2, 3])
     result = pd.to_datetime(arr, unit="ns")
index a50054f33f382ed913261e0cafd944c2fd86aaa3..d7342c652268872b0881feb8ae7a573f8a286b34 100644 (file)
@@ -500,7 +500,7 @@ class TestnanopsDataFrame:
 
     @pytest.mark.parametrize("ddof", range(3))
     def test_nansem(self, ddof, skipna):
-        sp_stats = pytest.importorskip("scipy.stats")
+        sp_stats = td.versioned_importorskip("scipy.stats")
 
         with np.errstate(invalid="ignore"):
             self.check_funs(
@@ -559,7 +559,7 @@ class TestnanopsDataFrame:
         return result
 
     def test_nanskew(self, skipna):
-        sp_stats = pytest.importorskip("scipy.stats")
+        sp_stats = td.versioned_importorskip("scipy.stats")
 
         func = partial(self._skew_kurt_wrap, func=sp_stats.skew)
         with np.errstate(invalid="ignore"):
@@ -573,7 +573,7 @@ class TestnanopsDataFrame:
             )
 
     def test_nankurt(self, skipna):
-        sp_stats = pytest.importorskip("scipy.stats")
+        sp_stats = td.versioned_importorskip("scipy.stats")
 
         func1 = partial(sp_stats.kurtosis, fisher=True)
         func = partial(self._skew_kurt_wrap, func=func1)
@@ -704,7 +704,7 @@ class TestnanopsDataFrame:
         self.check_nancorr_nancov_1d(nanops.nancorr, targ0, targ1, method="pearson")
 
     def test_nancorr_kendall(self):
-        sp_stats = pytest.importorskip("scipy.stats")
+        sp_stats = td.versioned_importorskip("scipy.stats")
 
         targ0 = sp_stats.kendalltau(self.arr_float_2d, self.arr_float1_2d)[0]
         targ1 = sp_stats.kendalltau(self.arr_float_2d.flat, self.arr_float1_2d.flat)[0]
@@ -714,7 +714,7 @@ class TestnanopsDataFrame:
         self.check_nancorr_nancov_1d(nanops.nancorr, targ0, targ1, method="kendall")
 
     def test_nancorr_spearman(self):
-        sp_stats = pytest.importorskip("scipy.stats")
+        sp_stats = td.versioned_importorskip("scipy.stats")
 
         targ0 = sp_stats.spearmanr(self.arr_float_2d, self.arr_float1_2d)[0]
         targ1 = sp_stats.spearmanr(self.arr_float_2d.flat, self.arr_float1_2d.flat)[0]
@@ -724,7 +724,7 @@ class TestnanopsDataFrame:
         self.check_nancorr_nancov_1d(nanops.nancorr, targ0, targ1, method="spearman")
 
     def test_invalid_method(self):
-        pytest.importorskip("scipy")
+        td.versioned_importorskip("scipy")
         targ0 = np.corrcoef(self.arr_float_2d, self.arr_float1_2d)[0, 1]
         targ1 = np.corrcoef(self.arr_float_2d.flat, self.arr_float1_2d.flat)[0, 1]
         msg = "Unknown method 'foo', expected one of 'kendall', 'spearman'"
index 52b5f636b1254ceddf869704a6378f4ea5012b8c..3d50300aa882fcfca2901029d8a4710fa2daca1b 100644 (file)
@@ -3,6 +3,7 @@ import types
 
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas.compat._optional import (
     VERSIONS,
     import_optional_dependency,
@@ -23,7 +24,7 @@ def test_import_optional():
 
 
 def test_xlrd_version_fallback():
-    pytest.importorskip("xlrd")
+    td.versioned_importorskip("xlrd")
     import_optional_dependency("xlrd")
 
 
index e226dac88b8824b68136b6e2efcba738e799c193..5f69946fb04e06a72c79f7a5e4366b240d77a914 100644 (file)
@@ -1014,7 +1014,7 @@ class TestToDatetime:
     @pytest.mark.parametrize("utc", [True, False])
     @pytest.mark.parametrize("tz", [None, "US/Central"])
     def test_to_datetime_arrow(self, tz, utc, arg_class):
-        pa = pytest.importorskip("pyarrow")
+        pa = td.versioned_importorskip("pyarrow")
 
         dti = date_range("1965-04-03", periods=19, freq="2W", tz=tz)
         dti = arg_class(dti)
@@ -1367,7 +1367,7 @@ class TestToDatetime:
 
     def test_to_datetime_tz_psycopg2(self, request, cache):
         # xref 8260
-        psycopg2_tz = pytest.importorskip("psycopg2.tz")
+        psycopg2_tz = td.versioned_importorskip("psycopg2.tz")
 
         # misc cases
         tz1 = psycopg2_tz.FixedOffsetTimezone(offset=-300, name=None)
@@ -3757,7 +3757,7 @@ def test_ignoring_unknown_tz_deprecated():
 
 def test_from_numeric_arrow_dtype(any_numeric_ea_dtype):
     # GH 52425
-    pytest.importorskip("pyarrow")
+    td.versioned_importorskip("pyarrow")
     ser = Series([1, 2], dtype=f"{any_numeric_ea_dtype.lower()}[pyarrow]")
     result = to_datetime(ser)
     expected = Series([1, 2], dtype="datetime64[ns]")
index c452382ec572bd24cf704c445f24f9af87947141..7cd9889e841e93cc2cc5b4f10c7bcad85216b775 100644 (file)
@@ -867,7 +867,7 @@ def test_to_numeric_dtype_backend(val, dtype):
 def test_to_numeric_dtype_backend_na(val, dtype):
     # GH#50505
     if "pyarrow" in dtype:
-        pytest.importorskip("pyarrow")
+        td.versioned_importorskip("pyarrow")
         dtype_backend = "pyarrow"
     else:
         dtype_backend = "numpy_nullable"
@@ -891,7 +891,7 @@ def test_to_numeric_dtype_backend_na(val, dtype):
 def test_to_numeric_dtype_backend_downcasting(val, dtype, downcast):
     # GH#50505
     if "pyarrow" in dtype:
-        pytest.importorskip("pyarrow")
+        td.versioned_importorskip("pyarrow")
         dtype_backend = "pyarrow"
     else:
         dtype_backend = "numpy_nullable"
@@ -908,7 +908,7 @@ def test_to_numeric_dtype_backend_downcasting(val, dtype, downcast):
 def test_to_numeric_dtype_backend_downcasting_uint(smaller, dtype_backend):
     # GH#50505
     if dtype_backend == "pyarrow":
-        pytest.importorskip("pyarrow")
+        td.versioned_importorskip("pyarrow")
     ser = Series([1, pd.NA], dtype="UInt64")
     result = to_numeric(ser, dtype_backend=dtype_backend, downcast="unsigned")
     expected = Series([1, pd.NA], dtype=smaller)
@@ -931,7 +931,7 @@ def test_to_numeric_dtype_backend_downcasting_uint(smaller, dtype_backend):
 def test_to_numeric_dtype_backend_already_nullable(dtype):
     # GH#50505
     if "pyarrow" in dtype:
-        pytest.importorskip("pyarrow")
+        td.versioned_importorskip("pyarrow")
     ser = Series([1, pd.NA], dtype=dtype)
     result = to_numeric(ser, dtype_backend="numpy_nullable")
     expected = Series([1, pd.NA], dtype=dtype)
@@ -971,7 +971,7 @@ def test_invalid_dtype_backend():
 
 def test_coerce_pyarrow_backend():
     # GH 52588
-    pa = pytest.importorskip("pyarrow")
+    pa = td.versioned_importorskip("pyarrow")
     ser = Series(list("12x"), dtype=ArrowDtype(pa.string()))
     result = to_numeric(ser, errors="coerce", dtype_backend="pyarrow")
     expected = Series([1, 2, None], dtype=ArrowDtype(pa.int64()))
index 5a75988e4ff80726bcde64cd66a66f3b9343db49..3852c7a9eda0be24a1d18802acbc93fe81508cdb 100644 (file)
@@ -6,6 +6,7 @@ from datetime import (
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas.compat import IS64
 from pandas.errors import OutOfBoundsTimedelta
 
@@ -324,7 +325,7 @@ class TestTimedeltas:
 
 def test_from_numeric_arrow_dtype(any_numeric_ea_dtype):
     # GH 52425
-    pytest.importorskip("pyarrow")
+    td.versioned_importorskip("pyarrow")
     ser = Series([1, 2], dtype=f"{any_numeric_ea_dtype.lower()}[pyarrow]")
     result = to_timedelta(ser)
     expected = Series([1, 2], dtype="timedelta64[ns]")
@@ -334,7 +335,7 @@ def test_from_numeric_arrow_dtype(any_numeric_ea_dtype):
 @pytest.mark.parametrize("unit", ["ns", "ms"])
 def test_from_timedelta_arrow_dtype(unit):
     # GH 54298
-    pytest.importorskip("pyarrow")
+    td.versioned_importorskip("pyarrow")
     expected = Series([timedelta(1)], dtype=f"duration[{unit}][pyarrow]")
     result = to_timedelta(expected)
     tm.assert_series_equal(result, expected)
index acfff14c179adb923d85d3ff78078acefb34df1c..6dac4304947ae91f84659d0411654e7c83410a9b 100644 (file)
@@ -22,7 +22,7 @@ from pandas.util.version import Version
 
 pytestmark = [pytest.mark.single_cpu]
 
-numba = pytest.importorskip("numba")
+numba = td.versioned_importorskip("numba")
 pytestmark.append(
     pytest.mark.skipif(
         Version(numba.__version__) == Version("0.61") and is_platform_arm(),
index 43d55a7992b3ce52255a6813e8b9e93b82a45324..6b07dce0dc5ffe205ea9df66a46c1b3e33a415c3 100644 (file)
@@ -1,6 +1,7 @@
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas.compat import is_platform_arm
 
 from pandas import (
@@ -12,7 +13,7 @@ from pandas.util.version import Version
 
 pytestmark = [pytest.mark.single_cpu]
 
-numba = pytest.importorskip("numba")
+numba = td.versioned_importorskip("numba")
 pytestmark.append(
     pytest.mark.skipif(
         Version(numba.__version__) == Version("0.61") and is_platform_arm(),
index 79c14f243e7cc93b395ea84e05ec6bc79942b79b..c30d50037c074f9d6a197e7800aec7de72a28929 100644 (file)
@@ -3,6 +3,7 @@ from functools import partial
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas import (
     DataFrame,
     Series,
@@ -17,7 +18,7 @@ from pandas.tseries import offsets
 
 @pytest.mark.parametrize("sp_func, roll_func", [["kurtosis", "kurt"], ["skew", "skew"]])
 def test_series(series, sp_func, roll_func):
-    sp_stats = pytest.importorskip("scipy.stats")
+    sp_stats = td.versioned_importorskip("scipy.stats")
 
     compare_func = partial(getattr(sp_stats, sp_func), bias=False)
     result = getattr(series.rolling(50), roll_func)()
@@ -27,7 +28,7 @@ def test_series(series, sp_func, roll_func):
 
 @pytest.mark.parametrize("sp_func, roll_func", [["kurtosis", "kurt"], ["skew", "skew"]])
 def test_frame(raw, frame, sp_func, roll_func):
-    sp_stats = pytest.importorskip("scipy.stats")
+    sp_stats = td.versioned_importorskip("scipy.stats")
 
     compare_func = partial(getattr(sp_stats, sp_func), bias=False)
     result = getattr(frame.rolling(50), roll_func)()
@@ -41,7 +42,7 @@ def test_frame(raw, frame, sp_func, roll_func):
 
 @pytest.mark.parametrize("sp_func, roll_func", [["kurtosis", "kurt"], ["skew", "skew"]])
 def test_time_rule_series(series, sp_func, roll_func):
-    sp_stats = pytest.importorskip("scipy.stats")
+    sp_stats = td.versioned_importorskip("scipy.stats")
 
     compare_func = partial(getattr(sp_stats, sp_func), bias=False)
     win = 25
@@ -56,7 +57,7 @@ def test_time_rule_series(series, sp_func, roll_func):
 
 @pytest.mark.parametrize("sp_func, roll_func", [["kurtosis", "kurt"], ["skew", "skew"]])
 def test_time_rule_frame(raw, frame, sp_func, roll_func):
-    sp_stats = pytest.importorskip("scipy.stats")
+    sp_stats = td.versioned_importorskip("scipy.stats")
 
     compare_func = partial(getattr(sp_stats, sp_func), bias=False)
     win = 25
@@ -75,7 +76,7 @@ def test_time_rule_frame(raw, frame, sp_func, roll_func):
 
 @pytest.mark.parametrize("sp_func, roll_func", [["kurtosis", "kurt"], ["skew", "skew"]])
 def test_nans(sp_func, roll_func):
-    sp_stats = pytest.importorskip("scipy.stats")
+    sp_stats = td.versioned_importorskip("scipy.stats")
 
     compare_func = partial(getattr(sp_stats, sp_func), bias=False)
     obj = Series(np.random.default_rng(2).standard_normal(50))
index 5052019ddb7264c4f81e99ccdd79d88d86865ec4..f69d23dd8ef4bca8fa2b238f03a301f309467467 100644 (file)
@@ -1,6 +1,7 @@
 import numpy as np
 import pytest
 
+import pandas.util._test_decorators as td
 from pandas import (
     DataFrame,
     Series,
@@ -35,7 +36,7 @@ def win_types_special(request):
 
 def test_constructor(frame_or_series):
     # GH 12669
-    pytest.importorskip("scipy")
+    td.versioned_importorskip("scipy")
     c = frame_or_series(range(5)).rolling
 
     # valid
@@ -47,7 +48,7 @@ def test_constructor(frame_or_series):
 @pytest.mark.parametrize("w", [2.0, "foo", np.array([2])])
 def test_invalid_constructor(frame_or_series, w):
     # not valid
-    pytest.importorskip("scipy")
+    td.versioned_importorskip("scipy")
     c = frame_or_series(range(5)).rolling
     with pytest.raises(ValueError, match="min_periods must be an integer"):
         c(win_type="boxcar", window=2, min_periods=w)
@@ -57,7 +58,7 @@ def test_invalid_constructor(frame_or_series, w):
 
 @pytest.mark.parametrize("wt", ["foobar", 1])
 def test_invalid_constructor_wintype(frame_or_series, wt):
-    pytest.importorskip("scipy")
+    td.versioned_importorskip("scipy")
     c = frame_or_series(range(5)).rolling
     with pytest.raises(ValueError, match="Invalid win_type"):
         c(win_type=wt, window=2)
@@ -65,14 +66,14 @@ def test_invalid_constructor_wintype(frame_or_series, wt):
 
 def test_constructor_with_win_type(frame_or_series, win_types):
     # GH 12669
-    pytest.importorskip("scipy")
+    td.versioned_importorskip("scipy")
     c = frame_or_series(range(5)).rolling
     c(win_type=win_types, window=2)
 
 
 @pytest.mark.parametrize("arg", ["median", "kurt", "skew"])
 def test_agg_function_support(arg):
-    pytest.importorskip("scipy")
+    td.versioned_importorskip("scipy")
     df = DataFrame({"A": np.arange(5)})
     roll = df.rolling(2, win_type="triang")
 
@@ -89,7 +90,7 @@ def test_agg_function_support(arg):
 
 def test_invalid_scipy_arg():
     # This error is raised by scipy
-    pytest.importorskip("scipy")
+    td.versioned_importorskip("scipy")
     msg = r"boxcar\(\) got an unexpected"
     with pytest.raises(TypeError, match=msg):
         Series(range(3)).rolling(1, win_type="boxcar").mean(foo="bar")
@@ -97,7 +98,7 @@ def test_invalid_scipy_arg():
 
 def test_constructor_with_win_type_invalid(frame_or_series):
     # GH 13383
-    pytest.importorskip("scipy")
+    td.versioned_importorskip("scipy")
     c = frame_or_series(range(5)).rolling
 
     msg = "window must be an integer 0 or greater"
@@ -108,7 +109,7 @@ def test_constructor_with_win_type_invalid(frame_or_series):
 
 def test_window_with_args(step):
     # make sure that we are aggregating window functions correctly with arg
-    pytest.importorskip("scipy")
+    td.versioned_importorskip("scipy")
     r = Series(np.random.default_rng(2).standard_normal(100)).rolling(
         window=10, min_periods=1, win_type="gaussian", step=step
     )
@@ -130,7 +131,7 @@ def test_window_with_args(step):
 
 
 def test_win_type_with_method_invalid():
-    pytest.importorskip("scipy")
+    td.versioned_importorskip("scipy")
     with pytest.raises(
         NotImplementedError, match="'single' is the only supported method type."
     ):
@@ -140,7 +141,7 @@ def test_win_type_with_method_invalid():
 @pytest.mark.parametrize("arg", [2000000000, "2s", Timedelta("2s")])
 def test_consistent_win_type_freq(arg):
     # GH 15969
-    pytest.importorskip("scipy")
+    td.versioned_importorskip("scipy")
     s = Series(range(1))
     with pytest.raises(ValueError, match="Invalid win_type freq"):
         s.rolling(arg, win_type="freq")
@@ -153,7 +154,7 @@ def test_win_type_freq_return_none():
 
 
 def test_win_type_not_implemented():
-    pytest.importorskip("scipy")
+    td.versioned_importorskip("scipy")
 
     class CustomIndexer(BaseIndexer):
         def get_window_bounds(self, num_values, min_periods, center, closed, step):
@@ -167,7 +168,7 @@ def test_win_type_not_implemented():
 
 def test_cmov_mean(step):
     # GH 8238
-    pytest.importorskip("scipy")
+    td.versioned_importorskip("scipy")
     vals = np.array([6.95, 15.21, 4.72, 9.12, 13.81, 13.49, 16.68, 9.48, 10.63, 14.48])
     result = Series(vals).rolling(5, center=True, step=step).mean()
     expected_values = [
@@ -188,7 +189,7 @@ def test_cmov_mean(step):
 
 def test_cmov_window(step):
     # GH 8238
-    pytest.importorskip("scipy")
+    td.versioned_importorskip("scipy")
     vals = np.array([6.95, 15.21, 4.72, 9.12, 13.81, 13.49, 16.68, 9.48, 10.63, 14.48])
     result = Series(vals).rolling(5, win_type="boxcar", center=True, step=step).mean()
     expected_values = [
@@ -210,7 +211,7 @@ def test_cmov_window(step):
 def test_cmov_window_corner(step):
     # GH 8238
     # all nan
-    pytest.importorskip("scipy")
+    td.versioned_importorskip("scipy")
     vals = Series([np.nan] * 10)
     result = vals.rolling(5, center=True, win_type="boxcar", step=step).mean()
     assert np.isnan(result).all()
@@ -294,7 +295,7 @@ def test_cmov_window_corner(step):
 )
 def test_cmov_window_frame(f, xp, step):
     # Gh 8238
-    pytest.importorskip("scipy")
+    td.versioned_importorskip("scipy")
     df = DataFrame(
         np.array(
             [
@@ -321,7 +322,7 @@ def test_cmov_window_frame(f, xp, step):
 
 @pytest.mark.parametrize("min_periods", [0, 1, 2, 3, 4, 5])
 def test_cmov_window_na_min_periods(step, min_periods):
-    pytest.importorskip("scipy")
+    td.versioned_importorskip("scipy")
     vals = Series(np.random.default_rng(2).standard_normal(10))
     vals[4] = np.nan
     vals[8] = np.nan
@@ -335,7 +336,7 @@ def test_cmov_window_na_min_periods(step, min_periods):
 
 def test_cmov_window_regular(win_types, step):
     # GH 8238
-    pytest.importorskip("scipy")
+    td.versioned_importorskip("scipy")
     vals = np.array([6.95, 15.21, 4.72, 9.12, 13.81, 13.49, 16.68, 9.48, 10.63, 14.48])
     xps = {
         "hamming": [
@@ -443,7 +444,7 @@ def test_cmov_window_regular(win_types, step):
 
 def test_cmov_window_regular_linear_range(win_types, step):
     # GH 8238
-    pytest.importorskip("scipy")
+    td.versioned_importorskip("scipy")
     vals = np.array(range(10), dtype=float)
     xp = vals.copy()
     xp[:2] = np.nan
@@ -456,7 +457,7 @@ def test_cmov_window_regular_linear_range(win_types, step):
 
 def test_cmov_window_regular_missing_data(win_types, step):
     # GH 8238
-    pytest.importorskip("scipy")
+    td.versioned_importorskip("scipy")
     vals = np.array(
         [6.95, 15.21, 4.72, 9.12, 13.81, 13.49, 16.68, np.nan, 10.63, 14.48]
     )
@@ -566,7 +567,7 @@ def test_cmov_window_regular_missing_data(win_types, step):
 
 def test_cmov_window_special(win_types_special, step):
     # GH 8238
-    pytest.importorskip("scipy")
+    td.versioned_importorskip("scipy")
     kwds = {
         "kaiser": {"beta": 1.0},
         "gaussian": {"std": 1.0},
@@ -638,7 +639,7 @@ def test_cmov_window_special(win_types_special, step):
 
 def test_cmov_window_special_linear_range(win_types_special, step):
     # GH 8238
-    pytest.importorskip("scipy")
+    td.versioned_importorskip("scipy")
     kwds = {
         "kaiser": {"beta": 1.0},
         "gaussian": {"std": 1.0},
@@ -663,7 +664,7 @@ def test_cmov_window_special_linear_range(win_types_special, step):
 
 def test_weighted_var_big_window_no_segfault(win_types, center):
     # GitHub Issue #46772
-    pytest.importorskip("scipy")
+    td.versioned_importorskip("scipy")
     x = Series(0)
     result = x.rolling(window=16, center=center, win_type=win_types).var()
     expected = Series(np.nan)
@@ -672,7 +673,7 @@ def test_weighted_var_big_window_no_segfault(win_types, center):
 
 
 def test_rolling_center_axis_1():
-    pytest.importorskip("scipy")
+    td.versioned_importorskip("scipy")
     df = DataFrame(
         {"a": [1, 1, 0, 0, 0, 1], "b": [1, 0, 0, 1, 0, 0], "c": [1, 0, 0, 1, 0, 1]}
     )
index 2c1912bce856dd2694447d820ea2c5124be9c1a0..3315b55c96fc863eb1669c16617c479c32ff7b74 100644 (file)
@@ -79,8 +79,8 @@ def skip_if_no(package: str, min_version: str | None = None) -> pytest.MarkDecor
 
     The mark can be used as either a decorator for a test class or to be
     applied to parameters in pytest.mark.parametrize calls or parametrized
-    fixtures. Use pytest.importorskip if an imported moduled is later needed
-    or for test functions.
+    fixtures. Use td.versioned_importorskip if an imported module is later
+    needed or for test functions.
 
     If the import and version check are unsuccessful, then the test function
     (or test case when used in conjunction with parametrization) will be
@@ -171,3 +171,22 @@ skip_copy_on_write_invalid_test = pytest.mark.skipif(
     get_option("mode.copy_on_write") is True,
     reason="Test not valid for Copy-on-Write mode",
 )
+
+def versioned_importorskip(*args, **kwargs):
+    """
+    (warning - this is currently Debian-specific, the name may change if upstream request this)
+
+    Return the requested module, or skip the test if it is
+    not available in a new enough version.
+
+    Intended as a replacement for pytest.importorskip that
+    defaults to requiring at least pandas' minimum version for that
+    optional dependency, rather than any version.
+
+    See import_optional_dependency for full parameter documentation.
+    """
+    try:
+        module = import_optional_dependency(*args, **kwargs)
+    except ImportError as exc:
+        pytest.skip(str(exc), allow_module_level=True)
+    return module